Skip to content

Tag: csv

keep x rows and delete all from csv file

I want to be able to specify how many rows I want to keep and delete the rest, also preserving the header. I found some code which let’s you delete the first 5 rows but how can I make it do what I want? For example if I have this CSV I just want to specify a number to my

XML file parsing with Python

I am having trouble parsing data in this manner for an XML file which is converted to a CSV: For the first column, I would like to get the general name tag (recordingSystem, Ports, etc) and concatenate it with the subNames in the row tags (closedFileCount, processedFileCount, etc) The tag where the subName is…

Order CSV with two digit numbers

I’m trying to create a leaderboard for a game, where after the game has been played, the python script accesses a CSV file (not ordered) and prints out the top 5 people with the highest score. Python seems to do this fine with single-digit numbers, but I can’t get it to work with 2 digit numbers. …

Python Dictionary to Multiple CSV files

So I have a dictionary of 98 elements and I need to write each key:value to a CSV file. For example: {‘Group1′:values,’Group2’:values}, etc… So in this example I would need two (2) csv files: Group1_output.csv Group2_output.csv I am thinking I need a for loop but I am getting a l…