Some database and spreadsheet packages can save-files with comma-separated value
ID: 3851759 • Letter: S
Question
Some database and spreadsheet packages can save-files with comma-separated values. (CSVs) as one way to export their data, so other applications can import them for further processing. Given a data tile with comma-separated fields, of the form: Full Name, Street Address, City, State, Zip, Phone Number leftarrow Column labels Jones, Bill, 235 S. Williams St., Denver, CO, 80221, (303) 244-7989 leftarrow Data line Smith, Tom, 404 Polk Ave., Los Angeles, CA, 90003, (213) 879-5612 leftarrow Dateline Write a shell script to reformat the data and print it out to "stout" in labeled, evenly-spaced columns as the following example, note the lengths of the label strings in the first line and the maximum string length in each column:Explanation / Answer
#!/bin/bash input="inputfile.csv" while IFS=',' read -r f1 f2 f3 f4 f5 f6 do echo "$f1 $f2 $f3 $f4 $f5 $f6" echo "--------- ------------ -------------- -------------- --------------- --------------" done while IFS=',' read -r f1 f2 f3 f4 f5 f6 do echo "$f1 $f2 $f3 $f4 $f5 $f6" doneRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.