![]() ![]() It allows programmers to say, write this data in the format preferred by Excel, or read data from this file which was generated by Excel, without knowing the precise details of the CSV format used by Excel. Though what I don't understand is how to format the things that are within the list so that the name can be separated from each of the number variables and in line with the header as I don't have much experience with for loops that many say can be an easy fix within my class if I have that down pat. The csv module implements classes to read and write tabular data in CSV format. ![]() I had a classmate say to read the lines that turns it into a list and adjust it from there with some formatting, and another classmate said I could probably format it without listing it although I found that the newline character "\n" appears at the end of each list index if turning it into a listĮx: This includes the importing of third party tools which shot down chances to use things like beautifultable like a few other friends have offered as an easier way out. csv Module: The CSV module is one of the modules in Python which provides classes for reading and writing tabular information in CSV file format. Our instructor wanted us to work with the "open" command and try and stay away from things that could make it less readable but still as compact as possible. Reading a CSV File There are various ways to read a CSV file that uses either the CSV module or the pandas library. I know it looks simple, and because it is. ![]() format making a mess of the indexes and sometimes somehow ending up with only single letters to appear: file_name = input("Enter the file name: ") I've gutted my code and broke it down into just the skeleton after trying with things like file_open.read().rstrip("\n) and. I can create the headers, though it may not be pretty code, but when I print the contents of the test file it usually turns out like this: Name Hour Total payĪnd I don't understand how to properly format it to look like a proper table that's right justified and properly in line with the actual headers, I'm not sure how to really tackle it or where to even start as I haven't made any real ground on this. I want to convert a text file that can be entered by a user that looks like this within the file: Lennon 12 3.33Īnd create it to fit a tabular format like this: Name Hours Total Pay I've been stuck on it for a while and I'm still very new to coding and wanted to know if anyone has an answer that I can understand and implement, hopefully I can learn from those much more experienced. I'm having issues trying to properly format a text file to fit the needed criteria for a school project. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |