+ 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.
4 odpowiedzi
+ 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
+ 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/
+ 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!
+ 1
Lisa Thanks for the information 😀👍