I have a CSV file with many rows and column. I wanted to create one folder for each row and within that folder have two files:
- First 5 columns
- Next columns
I have been able to create two cases
- I have been able to create two folders 'a','b' 'a' having all the files of first five columns. and vice-versa.
I have been able to create a single folder having the name of the time stamp. and all the files in it.
import pandas as pd import os from datetime import datetime from datetime import timestamp as ts data = pd.read_csv('test.csv')
if '10' not in os.listdir(os.getcwd()): os.mkdir(timestamp) if '50' not in os.listdir(os.getcwd()): os.mkdir('50')
def splitter(data, split = 3): timestamp = datetime.timestamp(datetime.now()) for i in data.itertuples():
data_1 = pd.Series(i[1:split+1]) data_2 = pd.Series(i[split+1:]) data_1.drop #print(data_1) data_1.to_csv(r'10.txt'.format(i[0]+1),mode = 'w',index = False) data_2.to_csv(r'50.txt'.format(i[0]+1),mode = 'w',index = False)splitter(data)
I want to have name of different folders having time as their name to stop redundancy