简体   繁体   中英

python cvs and xlrd: how to write csv file cell by cell

I used this method xls to csv converter to convert excel files(xls and xlsx) to csv files.

But in this example, it uses csv.write.writerow() method, and I cannot find any method related to write cell by cell from csv writer object .

So how can I write to csv cell by cell?

There isn't any built-in support for writing cell by cell (or column by column). Why do you want to do this anyway? If you are trying to convert an Excel file to CSV, it is simple enough to do it row by row. If for whatever reason you really just want to write a few specific cells, in a nonsequential manner, you have to manage those writes yourself, perhaps in a 2-dimensional array (a list of lists would work fine) and then write that data structure out row by row to the CSV.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM