The last bit of code worked a treat on a csv file. The only problem was that it got rid of leading\trailing spaces in the data. I only want the leading\trailing spaces in the first line removed. I tried the following, with my limited knowledge of Python: -
delim = "," x=0 with open("filtered_csv.csv", "r") as file: lines = [map(str.strip, line.split(delim)) for line in file] with open("filtered_csv.csv", "w") as file: for line in lines: if x==0: file.write(",".join(line) + "\n") x=x+1But all it did was to remove all the data and left only the header. I guess I need to do something different on the str.strip line but don't how to only iterate the first line.