I have a large list file paths pointing to csv files.
...SomeFileIDon'tNeed.csv
\001SMPL_1.csv
\001SMPL_2.csv
\001SMPL_3.csv
\001SMPL_4.csv
\001SMPL_5.csv
\001SMPL_6.csv
\002SMPL_1.csv
\002SMPL_2.csv
\002SMPL_3.csv
\002SMPL_4.csv
\002SMPL_5.csv
\002SMPL_6.csv
I want to split this list into sub-lists like so
[["\001SMPL_1.csv","\002SMPL_1.csv"],["\001SMPL_2.csv","\002SMPL_2.csv"],["\001SMPL_3.csv","\002SMPL_3.csv"],...]
This is because I need to combine all similar files into dataframes. So all files ending in _1 will be one df and files ending _2 will be another df, etc.
I wrote code that will split the original list into the sub-lists I want but it's not very efficient. I'm looking for a better way
#where f is the original list of file paths
dfs=[]
for i in range(len(f)):
temp=[]
for file in f:
count="_"+str(i)
if count in file:
temp.append(file)
dfs.append(temp)