r/pythonhelp • u/KeganBergi • Dec 08 '21
PYTHON ASSIGNMENT PLS SOMEONE LOL
Read in the included data file and write it to a file named sorted_data.txt with the same data, but order the columns in ascending alphabetical order.
https://www.dropbox.com/s/snhowdtcne6zuuf/MOCK_DATA-3.txt?dl=0
That is the link to the data file that is supposed to be initially read in.
1
Upvotes
3
u/[deleted] Dec 08 '21
Not signing into a Dropbox account account to open some random file from a stranger on the Internet.
Include a sample of the data showing the format in your post and also what you've done so far.
The standard way to read a text file would be,
It is possible to read all of the lines in a file in one go, but it is assumed you will want to process each line to extract the data into a required format.
If the file is formatted in a standard way such as CSV, comma separated values (other separators than comma can be used) then the CSV module will help.
This looks similar but the csv module reads data into a list rather than one string, saving you some work.
Good guide: https://realpython.com/python-csv/