-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathExcelUtils.py
37 lines (31 loc) · 1.17 KB
/
ExcelUtils.py
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
import sys
import os
import shutil
from Bio import SeqIO
import re
import boto3
import botocore
from subprocess import Popen, PIPE
import logging
import datetime
class ExcelUtils:
def read_sheet1(xfile):
df = pd.read_excel(xfile,sheet_name='Sheet1', index_col=None)
Name=df['User'][0]
Email=df['Email'][0]
Service=df['Service'][0]
return Name, Email, Service
def to_csv(xfile, sheetname):
df = pd.read_excel(xfile,sheet_name=sheetname, index_col=None)
# xpath = os.path.dirname(os.path.abspath(xfile))
xfilename = os.path.splitext(xfile)[0]
csvfile = xfilename + '.csv'
df.to_csv(csvfile, header=True, index=None)
return csvfile
def copy_sheet(xsrcfile, srcsheetname, xdstfile, dstsheetname):
df = pd.read_excel(xsrcfile,sheet_name=srcsheetname, index_col=None)
# This section is sample code that creates a worbook in the current directory with 3 worksheets
#df = pd.DataFrame(np.random.randn(10, 3), columns=list('ABC'))
writer = pd.ExcelWriter(xdstfile, engine='xlsxwriter')
df.to_excel(writer, sheet_name=dstsheetname, index=False)
writer.close()