In: Computer Science
What is the difference between a comma-delimited text file and a fixed-width text file? Why is it important that you understand the difference before you import data from a text file?
Okay all files are use to store multiple data items let's say I have a file that stores a list of students and their mobile numbers.
In a simple table in SQL or excel with a great interface we can easily distinguish them but in all these date are stored in form of simple text files in the background and there we need to use delimiter or some sort of property to distinguish the elements, and the CSV ( comma separated value) and fixed width text are two examples of that.
Now the reason we need to understand the file is because we need to tell the program how to extract and distinguish the items depending on the file type.
Example the file we took, with name and number
If saves as a CSV will look like
John,3674893827,Rita,6484028163,Andrew Garfield,7562518463
Now the thing is we know that each item is name then number then name and then number and so on but where the name ends and where the number started isn't something we can distinguish like if someone is named as Andrew2 will this be a name or number or I'm case we saw there and there father's name then how would you be able to distinguish that's why we have "," and on case to case basis other character to distinguish that one Elem has ended and other has started
Where as sometimes to keep things a little faster we keep the size fix, like 0-50th character is name 51-100th is number and then 101-150th is the next name, 151-200th is the number and so on and we fill the empty space with a stuffing like *** eg
John*****************
3674893827*********
Rita******************
.
.
And so on so now you know that line one will have the name and then 3 will have then and the even number will have there numbers.
So based on what type of files you are working on your data is read, with simple import function you have to tell the type of files so that the program in that library can extract the data from the file based on how it has been storing.
If there is any point which isn't clear put a comment, and I'll answer that
Hope it helps.