-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreate_csv_pandas_subdirectories.py
More file actions
54 lines (41 loc) · 2.06 KB
/
create_csv_pandas_subdirectories.py
File metadata and controls
54 lines (41 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import csv
from datetime import date
import glob
import os
import pandas as pd
# CREATE NEW CSV OF CONCATENATED PROOFS FROM EACH INDIVIDUAL CSV FILE
todays_date = str(date.today())
descriptor = input("Please enter a one word descriptor you would like to add to your filename. (If you would not like to add a descriptor, hit ENTER): ")
newfilename = "ProofMode_Collection_" + todays_date + "_" + descriptor + ".csv"
header = ['File Hash SHA256', 'Locale', 'SafetyCheckCtsMatch',
'Location.Provider', 'IPv6', 'IPv4', 'Location.Accuracy',
'Location.Latitude', 'Language', 'NetworkType', 'Network',
'Manufacturer', 'DataType', 'Hardware', 'ScreenSize', 'Wifi MAC',
'Notes', 'DeviceID', 'Location.Longitude', 'Location.Bearing',
'SafetyCheckBasicIntegrity', 'Location.Time', 'File Modified',
'CellInfo', 'SafetyCheck', 'Location.Altitude', 'SafetyCheckTimestamp',
'Proof Generated', 'File Path', 'Location.Speed', 'Unnamed: 30']
with open(newfilename, 'w', newline='') as csvfile:
csvwriter = csv.writer(csvfile, delimiter=',', quoting=csv.QUOTE_MINIMAL)
csvwriter.writerow(header)
# READ IN FILES
desired_date = input('What is the date for the files? Enter in YYYY-MM-DD format: ')
name_of_download = input('Type in the exact name of the folder you downloaded: ')
PATH = 'ProofModeFiles\\' + desired_date + '\\' + name_of_download
EXT = '.csv'
separator = ','
## READ IN NEW PROOF
from csv import reader
# for proof_file in glob.glob(folder_name + "\\*" + file_type):
for path, subdir, files in os.walk(PATH):
print("Path: ", path)
print("Subdir: ", subdir)
print("Files: ", files)
for proof_file in glob.glob(path + "\\*" + EXT):
print("Hello World")
current_proof = open(proof_file, newline='')
current_proof_df = pd.read_csv(current_proof)
second_row = current_proof_df.iloc[0 , :]
with open(newfilename, 'a+', newline='') as csvfile:
csvwriter = csv.writer(csvfile, delimiter=',')
csvwriter.writerow(second_row)