Skip to content

Commit e50a436

Browse files
authored
Merge pull request #272 from QuanMPhm/fix/quotechar
Fixing quotechar for names with commas
2 parents 25d8851 + b87ac87 commit e50a436

File tree

6 files changed

+18
-15
lines changed

6 files changed

+18
-15
lines changed

process_report/process_report.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ def merge_csv(files):
110110
invoice.COST_FIELD: pandas.ArrowDtype(pyarrow.decimal128(21, 2)),
111111
invoice.RATE_FIELD: str,
112112
},
113+
quotechar="|",
113114
)
114115
dataframes.append(dataframe)
115116

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Invoice Month,Project - Allocation,Project - Allocation ID,Manager (PI),Invoice Email,Invoice Address,Institution,Institution - Specific Code,SU Hours (GBhr or SUhr),SU Type,Rate,Cost
2-
2024-01,TestProject1,TP1,testpi1@bu.edu,testpi1@bu.edu,"123 Test St, Boston MA 02101",Boston University,BU,100,OpenShift CPU,0.013,50.00
3-
2024-01,TestProject2,TP2,testpi2@harvard.edu,testpi2@harvard.edu,"456 Harvard Ave, Cambridge MA 02138",Harvard University,HARVARD,200,OpenShift CPU,0.013,75.00
4-
2024-01,TestProject3,TP3,testpi3@mit.edu,testpi3@mit.edu,"789 MIT Blvd, Cambridge MA 02139",Massachusetts Institute of Technology,MIT,150,OpenShift CPU,0.013,100.00
5-
2024-01,NonbillableProject,NBP1,nonbillable@example.edu,nonbillable@example.edu,"999 Test Ave, Boston MA 02101",Test Institution,TEST,50,OpenShift CPU,0.013,25.00
2+
2024-01,TestProject1,TP1,testpi1@bu.edu,testpi1@bu.edu,|123 Test St, Boston MA 02101|,Boston University,BU,100,OpenShift CPU,0.013,50.00
3+
2024-01,TestProject2,TP2,testpi2@harvard.edu,testpi2@harvard.edu,|456 Harvard Ave, Cambridge MA 02138|,Harvard University,HARVARD,200,OpenShift CPU,0.013,75.00
4+
2024-01,TestProject3,TP3,testpi3@mit.edu,testpi3@mit.edu,|789 MIT Blvd, Cambridge MA 02139|,Massachusetts Institute of Technology,MIT,150,OpenShift CPU,0.013,100.00
5+
2024-01,NonbillableProject,NBP1,nonbillable@example.edu,nonbillable@example.edu,|999 Test Ave, Boston MA 02101|,Test Institution,TEST,50,OpenShift CPU,0.013,25.00
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Invoice Month,Project - Allocation,Project - Allocation ID,Manager (PI),Invoice Email,Invoice Address,Institution,Institution - Specific Code,SU Hours (GBhr or SUhr),SU Type,Rate,Cost
2-
2024-01,TestProject1,TP1,testpi1@bu.edu,testpi1@bu.edu,"123 Test St, Boston MA 02101",Boston University,BU,50,OpenStack CPU,0.013,30.00
3-
2024-01,TestProject2,TP2,testpi2@harvard.edu,testpi2@harvard.edu,"456 Harvard Ave, Cambridge MA 02138",Harvard University,HARVARD,80,OpenStack CPU,0.013,40.00
4-
2024-01,TestProject4,TP4,testpi4@northeastern.edu,testpi4@northeastern.edu,"360 Huntington Ave, Boston MA 02115",Northeastern University,NEU,120,OpenStack CPU,0.013,65.00
2+
2024-01,TestProject1,TP1,testpi1@bu.edu,testpi1@bu.edu,|123 Test St, Boston MA 02101|,Boston University,BU,50,OpenStack CPU,0.013,30.00
3+
2024-01,TestProject2,TP2,testpi2@harvard.edu,testpi2@harvard.edu,|456 Harvard Ave, Cambridge MA 02138|,Harvard University,HARVARD,80,OpenStack CPU,0.013,40.00
4+
2024-01,TestProject4,TP4,testpi4@northeastern.edu,testpi4@northeastern.edu,|360 Huntington Ave, Boston MA 02115|,Northeastern University,NEU,120,OpenStack CPU,0.013,65.00
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Invoice Month,Project - Allocation,Project - Allocation ID,Manager (PI),Invoice Email,Invoice Address,Institution,Institution - Specific Code,SU Hours (GBhr or SUhr),SU Type,Rate,Cost
2-
2024-01,TestProject1,TP1,testpi1@bu.edu,testpi1@bu.edu,"123 Test St, Boston MA 02101",Boston University,BU,1000,Storage,0.0001,20.00
3-
2024-01,TestProject3,TP3,testpi3@mit.edu,testpi3@mit.edu,"789 MIT Blvd, Cambridge MA 02139",Massachusetts Institute of Technology,MIT,2000,Storage,0.0001,35.00
2+
2024-01,TestProject1,TP1,testpi1@bu.edu,testpi1@bu.edu,|123 Test St, Boston MA 02101|,Boston University,BU,1000,Storage,0.0001,20.00
3+
2024-01,TestProject3,TP3,testpi3@mit.edu,testpi3@mit.edu,|789 MIT Blvd, Cambridge MA 02139|,Massachusetts Institute of Technology,MIT,2000,Storage,0.0001,35.00
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Invoice Month,Project - Allocation,Project - Allocation ID,Manager (PI),Cluster Name,Invoice Email,Invoice Address,Institution,Institution - Specific Code,SU Hours (GBhr or SUhr),SU Type,Rate,Cost
2-
2024-01,P4ID,P4ID,pi4@example.edu,ocp-test,pi4@example.edu,"123 Test St, Boston MA 02101",Boston University,BU,280,OpenShift CPU,0.013,100.0
3-
2024-01,P4ID,P4ID,pi4@example.edu,ocp-test,pi4@example.edu,"123 Test St, Boston MA 02101",Boston University,BU,280,OpenStack GPUA100SXM4,0.013,100
4-
2024-01,P5ID,P5ID,pi5@harvard.edu,ocp-test,pi5@harvard.edu,"456 Harvard Ave, Cambridge MA 02138",Harvard University,HARVARD,280,OpenShift CPU,0.013,200
5-
2024-01,P6ID,P6ID,pi6@mit.edu,ocp-test,pi6@mit.edu,"789 MIT Blvd, Cambridge MA 02139",MIT,MIT,280,OpenShift CPU,0.013,300
2+
2024-01,P4ID,P4ID,pi4@example.edu,ocp-test,pi4@example.edu,|123 Test St, Boston MA 02101|,Boston University,BU,280,OpenShift CPU,0.013,100.0
3+
2024-01,P4ID,P4ID,pi4@example.edu,ocp-test,pi4@example.edu,|123 Test St, Boston MA 02101|,Boston University,BU,280,OpenStack GPUA100SXM4,0.013,100
4+
2024-01,P5ID,P5ID,pi5@harvard.edu,ocp-test,pi5@harvard.edu,|456 Harvard Ave, Cambridge MA 02138|,Harvard University,HARVARD,280,OpenShift CPU,0.013,200
5+
2024-01,P6ID,P6ID,pi6@mit.edu,ocp-test,pi6@mit.edu,|789 MIT Blvd, Cambridge MA 02139|,MIT,MIT,280,OpenShift CPU,0.013,300

process_report/tests/unit/test_util.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class TestMergeCSV(TestCase):
2828
def setUp(self):
2929
self.header = ["Cost", "Name", "Rate"]
3030
self.data = [
31-
[1, "Alice", 25],
31+
[1, "Alice, Allison", 25],
3232
[2, "Bob", 30],
3333
[3, "Charlie", 28],
3434
]
@@ -41,7 +41,7 @@ def setUp(self):
4141
)
4242
self.csv_files.append(csv_file)
4343
dataframe = pandas.DataFrame(self.data, columns=self.header)
44-
dataframe.to_csv(csv_file, index=False)
44+
dataframe.to_csv(csv_file, index=False, quotechar="|")
4545
csv_file.close()
4646

4747
def tearDown(self):
@@ -61,6 +61,8 @@ def test_merge_csv(self):
6161
# Assert that the headers in the merged DataFrame match the expected headers
6262
assert merged_dataframe.columns.tolist() == self.header
6363

64+
assert merged_dataframe["Name"].iloc[0] == "Alice, Allison"
65+
6466

6567
class TestTimedProjects(TestCase):
6668
def setUp(self):

0 commit comments

Comments
 (0)