Python Forum
Using Python to loop csv files to open them
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using Python to loop csv files to open them
#1
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
Reply
#2
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.
Reply
#3
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
Reply
#4
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.
Reply
#5
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!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Loop through all files in a directory? Winfried 10 415 Apr-23-2024, 07:38 PM
Last Post: FortuneCoins
Question Right way to open files with different encodings? Winfried 2 233 Apr-23-2024, 05:50 PM
Last Post: snippsat
  Open files in an existing window instead of new Kostov 2 326 Apr-13-2024, 07:22 AM
Last Post: Kostov
  File loop curiously skipping files - FIXED mbk34 10 820 Feb-10-2024, 07:08 AM
Last Post: buran
  open python files in other drive akbarza 1 711 Aug-24-2023, 01:23 PM
Last Post: deanhystad
  How to loop through all excel files and sheets in folder jadelola 1 4,525 Dec-01-2022, 06:12 PM
Last Post: deanhystad
  How to open/load image .tiff files > 2 GB ? hobbyist 1 2,470 Aug-19-2021, 12:50 AM
Last Post: Larz60+
  Open and read multiple text files and match words kozaizsvemira 3 6,769 Jul-07-2021, 11:27 AM
Last Post: Larz60+
Question (solved) open multiple libre office files in libre office lucky67 5 3,355 May-29-2021, 04:54 PM
Last Post: lucky67
  Can't open files Lass86 5 2,457 Nov-10-2020, 07:18 PM
Last Post: jefsummers

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020