I have a "2016 excel file" Sb_test.xlsx
which I want to convert to .csv
file. However,
XLRDError: Unsupported format, or corrupt file: Expected BOF record; found b'<## NASC'
occured at line
wb = xlrd.open_workbook(r"D:/Sb_test.xlsx")
of the below code:
import tensorflow as tf
import pandas as pd
import os, xlrd, csv
def csv_from_excel():
print (xlrd.__VERSION__, xlrd.__file__) # suggested at google forum
wb = xlrd.open_workbook(r"D:/Sb_test.xlsx")
print (xlrd.__VERSION__, xlrd.__file__)
sh = wb.sheet_by_name('Basic_Classification')
your_csv_file = open('Sb_01_csv.csv', 'w')
wr = csv.writer(your_csv_file, quoting=csv.QUOTE_ALL)
for rownum in range(sh.nrows):
wr.writerow(sh.row_values(rownum))
your_csv_file.close()
csv_from_excel()
Looking for a solution I found out that I might be using the older version of xlrd
, but no, it is 1.2.0 (the most recent one)
And here an accepted answer suggests opening it using a text editor, which in my case looks like this:
Once I realized that
... that is definitely not Excel .xls format
what am I supposed to do know to convert the (whatever type) file to csv format?
All I want is to have a CSV type file to further try some machine learning stuff.
Thanks for your help.