0

How to delete an empty value in dataset (csv)?

I'm working on a huge dataset. I have to delete the entire row of a column, for any of its value is Nan.

27th Apr 2019, 10:07 AM
PAR2
PAR2 - avatar
1 Answer
+ 2
Hi, if you want to handle CSV files there are 2 possible ways to do it. You can use python module csv by importing it with >import csv< in your code (don’t type in <>). The csv object has a reader and a writer method. You can find more information in the csv documentation. There is also another module named pandas that can handle csv files. Pandas is open source and has to be installed on your system. You can find more information about pandas here: https://pandas.pydata.org/ This does cover the handling of reading and writing, but you have to write also some code for your demands as deleting or modifying data. Handling of files in case of adding, modifying or deleting data can not be done directly in the file. Following steps are required: 1 Read data from file to a data structure like list 2 Make your processing line by line (search for “None” or other items) deleting, modifying,... 3 Create new file for writing and add all data (modified / unmodified) to this file 4 Rename old file for backup reasons 5 Rename new file to original file name
28th Apr 2019, 10:36 AM
Lothar
Lothar - avatar