<jupyter_start><jupyter_text>Ugly To Pretty for CSVS Run on linux. Set an import path and an export path to folders.Will take every file in import directory that is a mathematica generated CSV and turn it into a nicely fomatted CSV in Output directory.  Paths<jupyter_code>importpath = "/home/jwb/repos/github-research/csvs/Individuals/Ugly/Stack/"
exportpath = "/home/jwb/repos/github-research/csvs/Individuals/Pretty/Stack/"<jupyter_output><empty_output><jupyter_text>Function<jupyter_code>import csv
import pandas as pd
import os

def arrayer(path):
    with open(path, "rt") as f: 
        reader = csv.reader(f)
        names = set()
        times = {}
        windows = []
        rownum = 0
        for row in reader:
                newrow = [(i[1:-1],j[:-2]) for i,j in zip(row[1::2], row[2::2])] #Drops the timewindow, and groups the rest of the row into [name, tally]
                rowdict = dict(newrow) 
                names.update([x[0] for x in newrow]) #adds each name to a name set
                l=row[0].replace("DateObject[{","").strip("{}]}").replace(",","").replace("}]","").split() #Strips DateObject string
                timestamp=':'.join(l[:3])+'-'+':'.join(l[3:]) #Formats date string
                windows.append(timestamp) #add timestamp to list
                times[timestamp] = rowdict #link results as value in timestamp dict
                rownum += 1

    cols = [[times[k][name] if name in times[k] else ' 0' for name in names ] for k in windows] #put the tally for each name across each timestamp in a nested list of Columns
    data = pd.DataFrame(cols,columns=list(names),index=windows) #Put into dataframe with labels
    return data.transpose()<jupyter_output><empty_output><jupyter_text>Run<jupyter_code>for filename in os.listdir(importpath):
    arrayer(importpath+filename).to_csv(exportpath+filename, encoding='utf-8')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12874408828166053, 'fraction_numerical': 0.007882291119285338, 'mean_word_length': 3.397228637413395, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '244858', 'license': 'MIT', 'n_tokens_mistral': 621, 'n_tokens_neox': 584, 'n_words': 174, 'path': 'company-affiliation/python/arrayify.ipynb', 'repo_name': 'IanOlin/github-research', 'size': '1903'}