0

I am trying to make a csv file for Python input that will be an input for dictionary conversion from English to Hindi. However whatever I type in Hindi in the csv file gets reduced to question marks. I have seen other people have asked the similar questions here (for a variety of diff languages) and have been asked to try saving the file in unicode-8 format.( When saving go to Tools>encoding) but even doing that hasn't worked for them and is not working for me.

DashingQuark
  • 105
  • 8
  • Are the question marks in the csv file or in your Python source? Is the string in python a `string` or a `unicode` string? – Ben Jun 24 '14 at 16:57
  • possible duplicate of [Reading a UTF8 CSV file with Python](http://stackoverflow.com/questions/904041/reading-a-utf8-csv-file-with-python) – John Y Jun 24 '14 at 16:58
  • Also related: http://stackoverflow.com/questions/1846135/python-csv-library-with-unicode-utf-8-support-that-just-works – John Y Jun 24 '14 at 17:02
  • I checked.The question marks are replacing the hindi text in my csv file itself. When I open the csv file after saving they have already been replaced. – DashingQuark Jun 24 '14 at 18:01
  • Thanks for the replies but No this question is not a duplicate of either of these questions.when I give this python statement print मोनिका it prints perfectly. So python can handle Hindi once it gets it,I should not have to use additional python modules to convert hindi code. I am stuck before that, trying to save it in the csv. – DashingQuark Jun 24 '14 at 18:05

1 Answers1

1

Yes, you want to save the csv file in UTF-8 format. Is this a file you are generating from a text editor, or exporting from some program, or generating in python?

In most text editors, when you go to Save As, you get the encoding option. Select Unicode UTF-8

GAEfan
  • 11,244
  • 2
  • 17
  • 33
  • Thanks, as I mentioned I am doing this in MS Office and selecting Unicode UTF-8 at save. But still the Hindi text gets converted to all question marks. – DashingQuark Jun 24 '14 at 18:02
  • Make sure you save in plain text, and not Word's standard rtf, format, with UTF-8 encoding. I no longer use Windows, but I remember I used to have to explicitly select plain text format. – GAEfan Jun 24 '14 at 20:00
  • Thanks GAEfan, but I specifically want to make a csv file.Trying out different file input formats on python. Tried it with json already and that works fine. – DashingQuark Jun 24 '14 at 21:32
  • 1
    A csv file is a plain text file, with a `.csv` extension. My guess is your Word program is saving it in rtf format, and not plain text. Save it as a `.txt` file, then change the extension to `.csv` – GAEfan Jun 24 '14 at 21:34