Phillip Pugh <pug...@me.com> Wrote in message:
> I am trying to decide if Python is the right toolset for me. I do a lot of 
> data analytics. Over the years I have used a lot of SQL and VBA, but the data 
> sources are getting bigger. I am thinking Python may be what I need to use, 
> but I am in the early stages of getting to know Python.  Can you point me to 
> a really good, intuitive resource for getting up to speed with data. 
> Something that would help with the following.
> 
> I have one text file that is 500,000 + records..  I need to read the file, 
> move "structured" data around and then write it to a new file. The txt file 
> has several data elements and is 300 characters per line. I am only 
> interested in the first two fields. The first data element is 19 characters. 
> The second data element is 6 characters. I want to rearrange the data by 
> moving the 6 characters data in front of the 19 characters data and then 
> write the 25 character data to a new file.  
> 
> I have spent some time digging for the correct resource, However being new to 
> Python and the syntax for the language makes it slow going.  I would like to 
> see if I can speed up the learning curve. Hopefully  can get some results 
> quickly then I will know how deep I want to go into Python.
> 

Open the two files, using the 'with' statement. Using a for loop,
 iterate over the input file. For each line, use substring
 operators to fetch each field. Then write second + first.  Maybe
 6 lines.

If you can get most of this, show it to us, and tell us where
 you're stuck.

-- 
DaveA

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to