How to create columns in a csv file and insert row under them in python scrapy
CSV is a Comma Saparated Values format. That basically means that it is a text file with some strings separated by commas and line-downs.
Each line down creates a row and each comma creates a column in that row.
I guess the simplest way to create a CSV file would be to create a Pythonic dict where each key is a column and the value for each column is a list of rows where None stands for the obvious lack of value.
You can then fill in your dict by appending values to the requested column (thus adding a row) and then easily transform the dict into a CSV file by iterating over list indexes and for each column either add a VALUE, entry in the file or a , entry for index-out-of-bound or a None value for the corresponding list.
For each row add a line down.
Please help me in creating columns and inserting rows under them in a csv file using python scrapy. I need to write scraped data into 3 columns. So first of all three columns are to be created and then data is to be entered in each row.