Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need to organize the data listed below. I've included the first few lines of the csv file and my current code. I'm having an

I need to organize the data listed below. I've included the first few lines of the csv file and my current code. I'm having an issue with the single quotes surrounding each list item and how to remove them. Any ideas on how to do it "cleaner" are appreciated as well. Thanks in advance!!

File Information:

frame_no,timestamp,size_px-darkorange,position_px_x-darkorange,position_px_y-darkorange,rx-darkorange,ry-darkorange,vx-darkorange,vy-darkorange,ax-darkorange,ay-darkorange,size_px-hotpink,position_px_x-hotpink,position_px_y-hotpink,rx-hotpink,ry-hotpink,vx-hotpink,vy-hotpink,ax-hotpink,ay-hotpink,size_px-lightorange,position_px_x-lightorange,position_px_y-lightorange,rx-lightorange,ry-lightorange,vx-lightorange,vy-lightorange,ax-lightorange,ay-lightorange,size_px-yellowneon,position_px_x-yellowneon,position_px_y-yellowneon,rx-yellowneon,ry-yellowneon,vx-yellowneon,vy-yellowneon,ax-yellowneon,ay-yellowneon,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 2408,81711.7,,,,,,,,,,7,456,2,,,,,,,9,402,194,,,,,,,10,215,144,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 2409,81744.1,,,,,,,,,,8,457,9,,,,,,,9,393,200,,,,,,,9,208,138,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 2410,81776.5,,,,,,,,,,8,458,19,,,,,,,9,383,206,,,,,,,9,202,133,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 2411,81811.5,,,,,,,,,,8,459,30,,,,,,,9,372,210,,,,,,,10,197,128,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 2412,81875.6,,,,,,,,,,8,458,51,,,,,,,9,352,219,,,,,,,9,186,116,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 2413,81911.7,,,,,,,,,,8,457,62,,,,,,,9,340,224,,,,,,,9,182,110,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 2414,81947.3,,,,,,,,,,8,456,74,,,,,,,9,330,228,,,,,,,9,179,105,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 2415,81976.6,,,,,,,,,,8,454,86,,,,,,,9,319,231,,,,,,,9,175,100,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 2416,82013.8,,,,,,,,,,8,451,98,,,,,,,9,310,234,,,,,,,9,173,94,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 2417,82044.4,,,,,,,,,,8,449,110,,,,,,,9,299,238,,,,,,,9,170,89,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 2418,82076.2,,,,,,,,,,8,445,122,,,,,,,9,288,240,,,,,,,9,168,85,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 2419,82111.9,,,,,,,,,,8,441,134,,,,,,,9,277,242,,,,,,,9,167,80,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 2420,82144.1,,,,,,,,,,8,437,146,,,,,,,9,267,244,,,,,,,9,167,76,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 2421,82176.2,,,,,,,,,,8,432,159,,,,,,,7,259,242,,,,,,,9,166,72,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 2422,82219.9,,,,,,,,,,8,427,171,,,,,,,9,247,247,,,,,,,9,167,69,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 2423,82244.2,,,,,,,,,,8,421,184,,,,,,,9,238,248,,,,,,,9,168,65,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 2424,82284.9,,,,,,,,,,8,415,195,,,,,,,9,227,249,,,,,,,9,169,62,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 2425,82312.1,,,,,,,,,,8,409,208,,,,,,,9,218,250,,,,,,,9,170,60,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 2426,82344,,,,,,,,,,8,402,219,,,,,,,9,209,250,,,,,,,10,172,58,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 2427,82376.1,,,,,,,,,,8,395,231,,,,,,,9,200,250,,,,,,,9,174,56,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 2428,82412,,,,,,,,,,8,387,243,,,,,,,9,192,250,,,,,,,9,177,55,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 2429,82444,,,,,,,,,,8,378,254,,,,,,,9,183,250,,,,,,,9,180,54,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 2430,82476.3,,,,,,,,,,8,371,265,,,,,,,9,175,250,,,,,,,10,183,54,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 2431,82512.1,,,,,,,,,,8,362,276,,,,,,,9,167,249,,,,,,,9,187,54,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 2432,82544,,,,,,,,,,8,352,286,,,,,,,9,160,248,,,,,,,9,190,55,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 2433,82575.9,,,,,,,,,,8,343,297,,,,,,,9,153,247,,,,,,,10,195,56,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 2434,82611.9,,,,,,,,,,8,333,306,,,,,,,9,146,246,,,,,,,9,199,58,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 2435,82644.2,,,,,,,,,,8,324,316,,,,,,,9,140,245,,,,,,,9,204,60,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 2436,82677.4,,,,,,,,,,8,313,326,,,,,,,9,135,244,,,,,,,9,208,63,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

Current Code:

frame_num = [] #empty lists for each item being orgazined time = [] px_hp = [] hp_x = [] hp_y = [] px_lo = [] lo_x = [] lo_y = [] px_yell = [] yell_x = [] yell_y = [] length_hp = [] length_yell = []

with open('Example_5.csv') as file: #looping through data and organizing it into appropriate lists #skip header line and second line file.readline() file.readlines(3) for line in file.readlines(): #creating loop to loop over all data line = line.strip().strip("'").split(',') #splitting data at "," frame_num.append(line[0]) time.append(line[1]) px_hp.append(line[11]) hp_x.append(line[12]) hp_y.append(line[13]) px_lo.append(line[20]) lo_x.append(line[21]) lo_y.append(line[22]) px_yell.append(line[29]) yell_x.append(line[30]) yell_y.append(line[31]) frame_num.pop(0) #removing first element from each list time.pop(0) px_hp.pop(0) hp_x.pop(0) hp_y.pop(0) px_lo.pop(0) lo_x.pop(0) lo_y.pop(0) px_yell.pop(0) yell_x.pop(0) yell_y.pop(0)

Current output of one of the lists. Need to remove the single quotes from each item:

image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Solaris 11.2 System Administration (oracle Press)

Authors: Harry Foxwell

1st Edition

007184421X, 9780071844215

More Books

Students also viewed these Databases questions

Question

1. Explain the 2nd world war. 2. Who is the father of history?

Answered: 1 week ago

Question

LO6 List the components of job descriptions.

Answered: 1 week ago

Question

LO3 Define job design and identify common approaches to job design.

Answered: 1 week ago