Plotting double-indexed CSV's

I am wanting to plot a series of CSV files, some of which I have saved as double-digit indexes (so for example, 2021-03-02_10), and I am facing an issue. When I initially try to call them up in the lookup-file code, 0, 2, 4, 6 and 8 show up, but 10 and 12 don’t. I then tried to save the index names of these CSV files to 00, 02, 04, 06 and 08 to take into account the double digits, but instead I receive an empty list. Does anyone have suggestions for how I can fix this problem?

To clarify, I am not looking to use glob. I attach the Github repository that contains the workbook I am currently working with (Copy5), and an example notebook that demonstrates the results I am looking to achieve (Copy3).

This is not a Jupyter-related issue. Think of it this way, if you ran all your code as a Python script, you’d have the same issues. Ideally, you’d seek a Python resource to post about this.

Ideally, if someone wanted to help you anywhere, you’d want to help them do it by making things easy. One way to do that is to post a minimum reproducible example, see here. Often while working out the minimum reproducible example, you’ll see where you went wrong. The notebooks you linked too are rather large, so that it is not readily clear how copy3 and 5 differ? In your post, you reference ‘lookup-file code’. Do you mean lookup_file_list? See how you aren’t helping others help you by reference the python object or variable name with the issue in your post? You didn’t even post a real example of your file names in your post.

It just looks like you aren’t parsing your file names very well.
Consider the following line:

if (i[-16:-6] == collection_date) and (i[-4:]=='.csv'):

i[-16:-6] looks wrong to me because isn’t your parsing attempt going to break when you have more than single digits after the character _ that is just in front of the .csv extension? Is your parsing code so complex because some files with not distinct or well-formatted names also also lurk in that directory? Are you familiar with the fnmatch module? Using fnmatch and str.split() more would probably help you. For example, in the file names seen among the output in the notebooks you linked to, you can easily get the collection_date with i.split("_")[1] so that you avoid i[-16:-6].

2 Likes