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
  File loop curiously skipping files - FIXED mbk34 10 685 Feb-10-2024, 07:08 AM
Last Post: buran
  open python files in other drive akbarza 1 632 Aug-24-2023, 01:23 PM
Last Post: deanhystad
  How to loop through all excel files and sheets in folder jadelola 1 4,331 Dec-01-2022, 06:12 PM
Last Post: deanhystad
  How to open/load image .tiff files > 2 GB ? hobbyist 1 2,383 Aug-19-2021, 12:50 AM
Last Post: Larz60+
  Open and read multiple text files and match words kozaizsvemira 3 6,673 Jul-07-2021, 11:27 AM
Last Post: Larz60+
Question (solved) open multiple libre office files in libre office lucky67 5 3,212 May-29-2021, 04:54 PM
Last Post: lucky67
  Can't open files Lass86 5 2,354 Nov-10-2020, 07:18 PM
Last Post: jefsummers
  Find specific subdir, open files and find specific lines that are missing from a file tester_V 8 3,487 Aug-25-2020, 01:52 AM
Last Post: tester_V
  Multiprocessing OSError 'too many open files' DreamingInsanity 3 10,199 Dec-27-2019, 04:50 PM
Last Post: DreamingInsanity
  Loop through folder of Excel Files and extract single column fioranosnake 2 4,478 Oct-28-2019, 05:19 PM
Last Post: fioranosnake

Forum Jump:

User Panel Messages

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