+ 2

Why i can't properly save a csv file created with pandas with the help of "open()" ,"write" and "close()"functions?

I made a matrix/dataFrame using pandas and saved it, but when i open that file in a csv reader app i saw that all columns are merged to one cloumn.

1st Aug 2021, 5:16 AM
UnTentetive
4 Respuestas
+ 4
For saving panda dataframes, there's the .to_df() method for that (I would prefer that over other export methods) https://datatofish.com/export-dataframe-to-csv/ If the csv doesn't look "right" in the reader app, the reader might use separators or decimal characters different from the one you intended for the file. In .to_csv() you can specify separators and decimals as you like
1st Aug 2021, 8:22 AM
Lisa
Lisa - avatar
+ 1
There is different library/module available to read and write csv files. Link to tutorial: https://realpython.com/JUMP_LINK__&&__python__&&__JUMP_LINK-csv/
1st Aug 2021, 5:18 AM
AKSHAY🇮🇳
AKSHAY🇮🇳 - avatar
+ 1
Use This Method: --------------------------------------------------------------- with open('filename.csv', 'wb') as writefile: #Your Code Here ---------------------------------------------------------------- This 'wb' attribute will make it write binary which as a CSV file is binary!
1st Aug 2021, 5:59 AM
Sancho Godinho
Sancho Godinho - avatar
+ 1
Lisa Thanks for the information 😀👍
1st Aug 2021, 8:32 AM
UnTentetive