Re: [Tutor] egg timer
Paula, Can you send the snippet of code where you’re having the syntax error? Thanks, Nitin Madhok > On Jun 24, 2018, at 5:21 PM, Paula Malimba wrote: > > Hello, > > I'm new to programming and am studying the book Begin to Code with Python. > I'm stuck in lesson 3, trying to make an egg timer. I keep having a syntax > error. > > Please help!!! > > Thanks, > Paula > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] CSV Read
Hello, I am a student learning python, and i am running into some difficulties. I am tryign to read a csv file that has different delimiters for different rows: Example: Format:V1.1 Model: R Step Size: 10mm Distance: 10cm Gain: 1000 X,Y 1,3 2,5 6,5 5,7 For the X,Y data, I have no problem getting it into the right cells, however I cannot separate the values after the colon for the first few rows. Its either one or the other. I am using pandas to read my CSV file. So far I have: d=pd.read_csv('read.csv',delimiter=',',skiprows=0) When I replace the delimiter for ':', it no longer works, and if i put sep=',|:' it does not work either. In the end I need to plot the x,y values and i will need some of the info in the rows above like the gain to manipulate the y data. If you have any tips for me I would be very grateful! Thanks, Giulia ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] CSV Read
On 25/06/18 20:35, Giulia Marcoux wrote: > Hello, > > I am a student learning python, and i am running into some difficulties. I > am tryign to read a csv file that has different delimiters for different > rows: Example: > > Format:V1.1 > Model: R > Step Size: 10mm > Distance: 10cm > Gain: 1000 Can you split your file here? That is could you just read the data from the first 5 lines (assuming its always in that kind of format) then spit the rest into a separate file (or stringbuffer?) and use CSV to analyze that? > X,Y > 1,3 > 2,5 > 6,5 > 5,7 > > For the X,Y data, I have no problem getting it into the right cells, > however I cannot separate the values after the colon for the first few > rows. Its either one or the other. A lot depends on the exact details of your file format. If the sample you've given is consistent with exactly the same header info in each (or at least some clear separating indicator - like X,Y in this case) Then its easy to split the data into two streams and process them separately. If the different formats are interlaced throughout the files things get more tricky. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] CSV Read
On 06/25/2018 01:35 PM, Giulia Marcoux wrote: > Hello, > > I am a student learning python, and i am running into some difficulties. I > am tryign to read a csv file that has different delimiters for different > rows: Example: > > Format:V1.1 > Model: R > Step Size: 10mm > Distance: 10cm > Gain: 1000 > > X,Y > 1,3 > 2,5 > 6,5 > 5,7 > > For the X,Y data, I have no problem getting it into the right cells, > however I cannot separate the values after the colon for the first few > rows. Its either one or the other. So you don't have a "csv file". You have a file with csv data, but also with headers. As Alan says, you want to divide it up so you've consumed the non-csv data and have only the csv data left (notice X,Y isn't part of your dataset either, even though it's in the format - it is column headers). Then it should be easy to process. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor