My question is as follows:
If I had some sample data in the form of delimited text, in this case comma-delimited (eg. canned_data.txt) and the format looked roughly like this:
name,age,occupation,status
"joe blow",21,salesman,married
"hanna montana,19,entertainer,single
etc...
I am confused with how to go about
1) importing this file into Python for reading line-by-line for eventual parsing,splitting, general manipulation to a new output file
2) the exact terminology/vocab (I have come across array,matrix,table, etc.)
So far I would do something like this:
Expand|Select|Wrap|Line Numbers
- # start of my module
- tInputName = raw_input("Enter the name of your delimited input file:") #canned_data.txt in the same directory as module
- tOutputName= raw_input("Enter the name of your output file:")
- getData = open(tInputName,r)
- getData = input.readlines()
- for line in getData
- getData = line.split(",") #my series of general data manipulation
- getData = line.upper #another eg of manipulation
- output.writelines(tOutputName)
- output.close()
- if output.close == true
- print "The file:", tOutputName, " was created"
- raw_input()
- else
- output.close ==false
- print "Failed creating ", tOutputName
- raw_input()
In a nutshell, could someone help me vett the above?
Sincerely,
Nick