CSV file parsing in Python, How?


Hey guys, I’m Rafiano Rizky Rubiantoro or you can just call me Ano (just like most of my friends do), one of the awesome members of allocateam development team. My first task in this first Sprint is basically just learning about file parsing in Python programming language, specifically for CSV file. Since now I know how, it’s gonna be better if I share with the world, isn’t it?


There are actually many Python modules that can do this like csv module, but I chose pandas. Probably you’re starting to ask “Why? Why pandas?”. Pandas modules do have many features for data analysis. Not only CSV files, pandas can also parse various file extensions, one of them is the most popular sheet extension, XLS. That was the main reason, so when user wants to upload XLS file rather than CSV, as a developer I don’t have to refactor bunch of codes because whether you parse CSV or XLS files, pandas translate them into a two-dimensional labeled data structures called DataFrame.


Never heard of DataFrame? I’ll tell you now. DataFrame originally discovered in R programming language. As it’s a two-dimensional, each row of the grinds are values of an instance and the column is a vector containing data for a specific variable. Actually there are many things you can do in pandas DataFrame, but in the case of what I need, I could iterate over rows and access specific cells I need in order to be processed in my program.


To know what are the methods that can be used, you just can access pandas documentation in https://pandas.pydata.org/pandas-docs/stable/


So, I think that’s all for now. If you have any question about pandas, just put it down in the comment section below. I’m willing to help. Cheers ^_^


References:

0 komentar:

Post a Comment