## Parsing A Data File (Python For Beginner) Somet...
## Parsing A Data File (Python For Beginner) Somet...
com
home / study / engineering / computer science / computer science questions and answers / ## parsing a data file (python for beginner) sometime…
```
Continue to post
Ling,Mai,55900
Johnson,Jim,56500
19 questions remaining
Jones,Aaron,46000
Jones,Chris,34500
Swift,Geoffrey,14200
Xiong,Fong,65000
```
phone to post a question
We'll send you a one-time download
Process the records and display the results formatted as a
table, evenly spaced, as shown in the example link
output.
```
### CONSTRAINTS
- Write your own code to parse the data. Don’t use a CSV
parser.
Expert Answer
col1_width=0
col2_width=0
col3_width=0
try:
line=line.replace("\n","") #removes the new line
line=line.split(",")
#seperates the line at comma
if(col1_width<len(line[0])):
col1_width=len(line[0])
if(col2_width<len(line[1])):
col2_width=len(line[1])
if(col3_width<len(line[2])):
col3_width=len(line[2])
https://www.chegg.com/homework-help/questions-and-answers/parsing-data-file-python-beginner-sometimes-data-comes-structured-format-break-tur… 1/3
7/9/2021 ## Parsing A Data File (python For Beginner) Somet... | Chegg.com
fp.close() #closes the file
Textbook Solutions Expert Q&A
data.sort(key=sortBySalary) #sorts the
data based on salary
Study Pack Practice
header_col1="Last"+"
"*(col1_width-4+1)
header_col2="First"+" "*(col2_width-5+1)
header_col3="Salary"+" "*(col3_width-6+1)
print("{}{}{}".format(header_col1,header_col2,header_col3))
#printing the header
print("-"*(col1_width+col2_width+col3_width+4))
#printing the lines
col2=line[1]+"
"*(col2_width-len(line[1])+1)
col3="{:,}".format(int(line[2]))+"
"*(col3_width-len(line[2])+1)
print("{}{}${}".format(col1,col2,col3)) #printing each
record
print("File Error")
Hide comments
Comments
You commented
how about getting the highest wages to start with. Reverse of this output?
Leave a comment
Post comment
https://www.chegg.com/homework-help/questions-and-answers/parsing-data-file-python-beginner-sometimes-data-comes-structured-format-break-tur… 2/3
7/9/2021 ## Parsing A Data File (python For Beginner) Somet... | Chegg.com
Python programming.
Develop a script to
Please show your work. convert
between Hex
(Hexadecimal)
COMPANY
CHEGG NETWORK
CUSTOMER SERVICE
https://www.chegg.com/homework-help/questions-and-answers/parsing-data-file-python-beginner-sometimes-data-comes-structured-format-break-tur… 3/3