I am trying to convert the first column of multiple (I mean like a lot!) of .txt files from wavelength (some in nanometers and some in micrometers) to wavenumber (cm^-1). Then, finally, I want to convert all the .txt files into .csv files.
Currently using:
Jupyter QtConsole 5.3.2 Python 3.9.13 (main, Aug 25 2022, 18:29:29)
THIS IS MY CURRENT CODE
import os
import pandas as pd
for dirName, subdirlist, fileList in os.walk('C:\\Users\Me\Documents\1testcopy') :
>>for filename in fileList:
>>>if fname.endswith('.txt'):
>>>>df = pd.read_csv(fname, "sep=\t", header=None)
>>>>df[0] = (1/df[0]) * 10000000
>>>>df.to_csv(fname.replace('.txt', '.csv'), index=False, header=False)`
Sometimes it just doesn't respond. Other times, it says
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
But I try all the different ways to write the path. I cannot seem to figure out what is going on. I would appreciate any help on this!