1
import pandas as pd

df=pd.DataFrame(record,columns['Title','Category','Headline','Summary','ImgLink','Details'])

df

df.to_csv("page1.csv",encoding='utf-8')

enter image description here

I want to store in this format

enter image description here

But file save in this format

1 Answers1

2

The problem with CSV is that it is a text file. To show it as UTF-8, you need to do something different. To open the csv file, don't double click on the csv file.

The following is for Excel 2007: for your version of Excel, it may be slightly different.

  1. Open Excel
  2. Select the Data Menu
  3. Select the From Text option
  4. Select the CSV file
  5. Make sure the File origin is set to 65001: Unicode (UTF-8). You should now see the Urdu/Arabic.
  6. Set the delimiters

You should now see the file as expected.

If you wish to double click on the file, do not save it as CSV. Save it as xlsx using either openpyxl or xlsxwriter.

Alternatively, use LibreOffice Calc as your default for opening CSV files - it goes straight into the LibreOffice Calc equivalent of From Text

cup
  • 7,589
  • 4
  • 19
  • 42