<jupyter_start><jupyter_text>Timing runs  Using openpyxl<jupyter_code>outpath_opxl = csv_dir / 'openpyxl_test.csv'<jupyter_output><empty_output><jupyter_text>Loading:<jupyter_code>%%timeit
xlsx = openpyxl.load_workbook(filename)<jupyter_output>59.3 s ± 2.23 s per loop (mean ± std. dev. of 7 runs, 1 loop each)<jupyter_text>Writing:<jupyter_code>xlsx = openpyxl.load_workbook(filename)
%%timeit
sheet = xlsx.active
with open(outpath_opxl, 'w', newline="") as dest:
    c = csv.writer(dest)
    for r in sheet.iter_rows():
        c.writerow([cell.value for cell in r])<jupyter_output>11.5 s ± 981 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)<jupyter_text>Using pandas<jupyter_code>outpath_pd = csv_dir / 'pandas_test.csv'<jupyter_output><empty_output><jupyter_text>Loading<jupyter_code>%%timeit
df = pd.read_excel(filename, engine='openpyxl')<jupyter_output>1min 11s ± 3.07 s per loop (mean ± std. dev. of 7 runs, 1 loop each)<jupyter_text>Writing<jupyter_code>df = pd.read_excel(filename, engine='openpyxl')
%%timeit
df.to_csv(outpath_pd, index=False)
import os

os.system('say "timing test complete"')<jupyter_output><empty_output><jupyter_text>Checking resultant csv files<jupyter_code># Exported from openpyxl directly
opdf = pd.read_csv(outpath_opxl)
opdf.head()
# Exported from pandas
pddf = pd.read_csv(outpath_pd)
pddf.head()
opdf.info()
pddf.info()<jupyter_output><class 'pandas.core.frame.DataFrame'>
RangeIndex: 541909 entries, 0 to 541908
Data columns (total 8 columns):
 #   Column       Non-Null Count   Dtype  
---  ------       --------------   -----  
 0   InvoiceNo    541909 non-null  object 
 1   StockCode    541909 non-null  object 
 2   Description  540455 non-null  object 
 3   Quantity     541909 non-null  int64  
 4   InvoiceDate  541909 non-null  object 
 5   UnitPrice    541909 non-null  float64
 6   CustomerID   406829 non-null  float64
 7   Country      541909 non-null  object 
dtypes: float64(2), int64(1), object(5)
memory usage: 33.1+ MB
{'fraction_non_alphanumeric': 0.12147177419354839, 'fraction_numerical': 0.055443548387096774, 'mean_word_length': 4.37940379403794, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 26, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '251742', 'license': 'MIT', 'n_tokens_mistral': 850, 'n_tokens_neox': 763, 'n_words': 176, 'path': 'notebooks/2.0-jk-excel-to-csv.ipynb', 'repo_name': 'jaredkeil/customer-segmenter', 'size': '1984'}