I have a folder of 310 .csv files. Here is a sample of what the contents look like
I need to create a program that goes through all the files, lists the file name, then lists the top 4 values from the table and the x-value associated with it. Ideally this would all be saved to a text doc but as long as it prints in a readable format that would be ideal.
Asked
Active
Viewed 69 times
0

DSharp7476
- 11
- 3
1 Answers
0
So, what is stopping you? Loop through the files, use pandas.read_csv
to import each csv file and merge/join them all into one DataFrame
. Use slicing to select the 4 top rows, and you can always print/visualize anything directly in a Jupyter Notebook. Exporting can be done using df.to_csv
or any other method and if you need a short introduction to pandas
, look here.
Keep in mind that it is always a good idea, to include a Minimal, Reproducible Example. Especially for a complicated merge operation between many DataFrames, this could help you a lot. However, there is no way around some research.

Confused Learner
- 386
- 2
- 9