I try to read a text file, via:
pd.read_fwf('File.txt')
However, I can't pd.DataFrame
get the columns to be located correctly
index | Title\tProgram\tEmployee\tLast Name and First Name\tTerm |
---|---|
0 | 13\t961000\t452345\tJORGEMORALES\t2020-06-01 |
1 | 1\t210200\t46445\tMAURICIODIAZ\t2020-06-01 |
two | 22\t11000\t7564345\tRAULMORALES\t2020-09-01 |
I have also tried the following codes and got the same result:
pd.read_fwf('File.txt',encoding='latin1', sep = '\t')
pd.read_fwf('File.txt',encoding='latin1', delim_whitespace= True)
Is that
read_fwf()
according to the documentation tells us:That is, this function is used to read tables with fixed-length columns, and your example is not of this type. Your data is of type
CSV
, only it seems that the separator is not a comma but a tab, so you should use the classicread.csv()
:This is just an example from your data, reading from a file is much easier: