Created
February 14, 2022 22:25
-
-
Save aitoehigie/efcb48257639bc7382ae21a52fe60a50 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tempfile | |
import os | |
import string | |
import random | |
import subprocess | |
import requests | |
import openai | |
import pandas as pd | |
import csv | |
import openpyxl | |
def convert_to_csv(file): | |
if file.endswith('.xlsx') or file.endswith('.xls'): | |
wb = openpyxl.load_workbook(file) | |
workbook_sheets = wb.sheetnames | |
for sheet_name in workbook_sheets: | |
sheet = wb[sheet_name] | |
col = csv.writer(open(f"{sheet_name}.csv", "w", newline="")) | |
for r in sheet.rows: | |
col.writerow([cell.value for cell in r]) | |
else: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment