Python Forum

Full Version: Using Python to loop csv files to open them
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi

I am new to Python.

I would like to know if Python can do the following

1) In an excel file, I have a list of the paths of CSV files.

2) Starting from Row 1 in the Excel, I want Python to
a. open the CSV file,
b. use Regex expression to find some values in the CSV file,
c. evaluate the values,
d. output the result into the Excel file.

3) Then Python will move to Row 2 and repeat the above. The above steps are repeated until the last used row in the Excel file.

First of all, can Python open the CSV file based on the path in the Excel?

Thank you
All those things seem doable. You can read a string from an Excel cell, and you can turn a string into a path for opening. Give it a shot and let us know if you run into problems.
Hi

Thank you for the reply. For the above that I wish to do, is it better to use R or Python? What are the pros & cons? Eg, for Regex expression is it better to use Python or R

Thank you
I'm not sure how many people here know R. I don't know it in any depth, so I can't come close to offering information about it.
If you calculate a lot of statistics stuff like means, standard deviations etc., then perhaps R is right for you. Python is more suited for "general processing", so it is better to use Python if the actual evaluation of data from the csv files are not pure statistics.

Regarding your question, I strongly suggest you to watch this tutorial!