Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I'm trying to save a file with text information into csv format.
However, after I use 'to_csv' in pandas (without specifying anything) save the file and I then use pd.read_csv to reopen the file. It will give me this error message:
ParserError: Error tokenizing data. C error: Buffer overflow caught - possible malformed input file.
But if I read the csv file in pandas like pd.read_csv('file.csv',lineterminator='\n'). It will open the file properly.
However, I need to use a software to process these text file, and the software opens the file the same way as how Excel opens the csv file, and I cannot specifying lineterminator='\n' like I did in the python. If I open the csv file using that software, some text in the column will go to other rows.
The text between the index 378 and 379 is supposed to be together in 378 row. However, they goes to other rows and go to the index column.
id text
378 1 Good morning. This row's text goes to the following rows
Dot dot NaN NaN
HELLO NaN NaN
Apple NaN NaN
379 2 This row is correct
Does anyone know how to solve this problem when i use pandas.to_csv to save the dataframe? what should i specify if i want to open the file properly in a software like Excel?
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.