Skip to content

Tag: csv

Import Data from .csv file into mysql using python

I am trying to import data from two columns of a .csv file (time hh:mm, float). I created a database and a table in mysql. If I run the program with executemany(), result is the following: [’01:00′, ‘1’] ‘-1 was inserted.’ and after this I do get the error code: Not all par…

CSV data to MySQL table

I am trying to insert rows from a csv file into a MySQL table. I tried this code Nb: tab is a table with two columns name (varchar 20) and nb_cases (double) I get this error: DataError: (1265, “Data truncated for column ‘nb_cases’ at row 1”) Answer your number doesn’t fit it must…

Split CSV values on single row into individual rows

I have a Python script that outputs a text file with thousands of random filenames in a comma separated list, all on a single row. I want to take each value in the list and put it into its own row in a new CSV file. I’ve tried some variations of awk with no success. What’s the best way to

How to remove NaN on CSV?

I have a .csv file of a table consisting of 12 col and 30k rows. One of the col is ‘mentions’, some of the data are empty (NaN). I am trying to remove all the rows where mentions = NaN. I don’t want to fill it with new data. I just wanna remove those rows so they wont be part

Python: Write list of lists to CSV

In my python script I’m having a list that has the following structure: and so on. I want to write this list to csv file in a way that every element is in separate row and every string in one element is in separate column. So I want to end up with the following result in csv file: Currently I