As the first step of a larger process, I’m trying to get the column names from some .dat files. I’m getting the "FileNotFoundError: [Errno 2] No such file or directory:" error
, but I’m passing it the directory path and it is telling me the first file in the folder, so it doesn’t seem to be the usual suspect of the relative/absolute path issue.
dir_path = "C:/Projects/acs5-2022/Datasource/TestSample"
column_list = []
for path, subs, file_names in os.walk(dir_path):
for file in file_names:
datafile = pandas.read_csv(file, delimiter="|")
for col in datafile.columns:
col.append(column_list)
print(column_list)
And I get:
FileNotFoundError: [Errno 2] No such file or directory: 'acsdt5y2022-b02009.dat'
acsdt5y2022-b02009.dat
is the first file in the TestSample
folder. I’m not giving it that information, so it can, in fact, see the files.
The header in this particular file is GEO_ID|B02009_E001|B02009_M001
I’ve tried various formats for the path directory – "C:/.....", r"C:\.....", "C:\\....."
– it doesn’t seem to matter.
Any suggestions? Is it the .dat format? Is it the pipes? I’m using PyCharm and I’ve seen some posts on that, but again, I’m specifying the directory.
Thank you in advance for any direction you can give me!