0

I am trying to open csv table and use it with sqlite. I've tried several methods but they all result with a table which inserts \n instead of a blank space ' ' or  letters. I tried to change the encoding but everything i do seems to end up with the same format. Please help! This is my code:

import csv_to_sqlite

options=csv_to_sqlite.CsvOptions(typing_style='full', encoding='windows-1250')
input_file = ["./datasets/choco_flavors/flavors_of_cacao.csv"] 
csv_to_sqlite.write_csv(input_file, "flavors_of_cacao.sqlite", options)
con=sqlite3.connect("flavors_of_cacao.sqlite")
filter_data=pd.read_sql_query("""SELECT * FROM flavors_of_cacao""",con)

and the result of the first column title is "Company \n(Maker-if known)"

Thank you

Nat
  • 81
  • 1
  • 6
  • 1
    This is amost certainly an encoding issue, maybe your source is stored in UTF-8 ? If I store a UTF-8 text `Å Æ Ø` and read as Windows 1251 (Western europe), the text reads `Ã… Æ Ø` (so characters similar to what you see). If you are "lucky" the Win1250 encoding of the bytes contain  plus linefeed. Could you paste example of original source file ? – MyICQ Oct 28 '21 at 10:03
  • This is the first row of the csv file: "Company  (Maker-if known)","Specific Bean Origin or Bar Name",REF,"Review Date","Cocoa Percent","Company Location",Rating,"Bean Type","Broad Bean Origin" – Nat Oct 28 '21 at 11:09

0 Answers0