... | ... | @@ -16,9 +16,11 @@ |
|
|
|
|
|
4. As a data engineer I deal with a lot of different types of data types, like integers, floats, and booleans. It would be very convenient if the input data was automatically formatted to their respective data types in the JSON file.
|
|
|
|
|
|
5. As a
|
|
|
5. As a novice in CS I might forget to name a header field in my data set, I’d like the option to catch any simple errors and to fix them.
|
|
|
|
|
|
6. As a
|
|
|
6. As a data analyst I want to be able to format my output data in specific ways so that it’s easier to read and analyze.
|
|
|
|
|
|
7. As a data analyst, I would like a quick way to replace a data value that I entered multiple times with another value.
|
|
|
|
|
|
## TDD Examples
|
|
|
|
... | ... | @@ -38,7 +40,7 @@ The program can separate different objects into separate lines |
|
|
The program will find occurrences of the misspelt value, replace with the correct value provided by the user, and return the number of values replaced,
|
|
|
|
|
|
## Executable Test Cases
|
|
|
|
|
|
_Outputs are from the Terminal._
|
|
|
#### Scenario 1
|
|
|
scenario1.csv:
|
|
|
|
... | ... | @@ -51,83 +53,97 @@ Command: `./csv2json scenario1.csv del “;”` |
|
|
Output:
|
|
|
|
|
|
```
|
|
|
{"date":"2020-01-21";"county";"Snohomish";"state";"Washington";"fips";"53061";"cases";"1";"deaths";"0"}
|
|
|
{"date":"2020-01-21","county":"Snohomish","state":"Washington","fips":"53061","cases":"1","deaths","0"}
|
|
|
```
|
|
|
#### Scenario 2
|
|
|
scenario2.csv:
|
|
|
|
|
|
```
|
|
|
|
|
|
date,county,state,fips,cases,deaths
|
|
|
2020-01-21,Snohomish,Washington,53061,1,0
|
|
|
```
|
|
|
Command: `./idk scenario2.csv`
|
|
|
|
|
|
Output:
|
|
|
|
|
|
```
|
|
|
|
|
|
Number of fields do not match
|
|
|
```
|
|
|
#### Scenario 3
|
|
|
scenario3.csv:
|
|
|
|
|
|
```
|
|
|
|
|
|
date,county,state,fips,cases,deaths
|
|
|
3020-21-91,Snohomish,Washington,53061,1,0
|
|
|
```
|
|
|
Command: `./csv2json scenario3.csv -c [1-2][0-9]{3}-[0-1][0-9]-[0-3][0-9]`
|
|
|
Command: `./csv2json scenario3.csv -c date:[1-2][0-9]{3}-[0-1][0-9]-[0-3][0-9]`
|
|
|
|
|
|
Output:
|
|
|
|
|
|
```
|
|
|
|
|
|
Invalid “date” format
|
|
|
```
|
|
|
#### Scenario 4
|
|
|
scenario4.csv:
|
|
|
|
|
|
```
|
|
|
|
|
|
name, usernum, employed
|
|
|
“Bryan”, “1”, “true”
|
|
|
```
|
|
|
Command: `./csv2json scenario4.csv -f`
|
|
|
|
|
|
Output:
|
|
|
|
|
|
```
|
|
|
|
|
|
[{“name”: “Bryan”, usernum: 1, employed: true}]
|
|
|
```
|
|
|
#### Scenario 5
|
|
|
scenario5.csv:
|
|
|
|
|
|
```
|
|
|
|
|
|
name, usernum, employed,
|
|
|
“Bryan”, “1”, “true”, “Simon Fraser University”
|
|
|
```
|
|
|
Command: `./csv2json scenario5.csv -hf`
|
|
|
|
|
|
Output:
|
|
|
|
|
|
```
|
|
|
|
|
|
Data field is missing header name
|
|
|
Please name the data field:
|
|
|
```
|
|
|
#### Scenario 6
|
|
|
scenario6.csv:
|
|
|
|
|
|
```
|
|
|
|
|
|
date,county,state,fips,cases,deaths
|
|
|
2020-01-21,Snohomish,Washington,53061,1,0
|
|
|
```
|
|
|
Command: `./idk scenario6.csv`
|
|
|
Command: `./csv2json scenario6.csv -sl`
|
|
|
|
|
|
Output:
|
|
|
|
|
|
```
|
|
|
|
|
|
"Date":"2020-01-21"
|
|
|
"county":"Snohomish"
|
|
|
"state":"Washington"
|
|
|
"Fips":"53061"
|
|
|
"cases":"1"
|
|
|
"deaths":"0"
|
|
|
```
|
|
|
#### Scenario 7
|
|
|
scenario7.csv:
|
|
|
|
|
|
```
|
|
|
|
|
|
date,name,favourite food,
|
|
|
2020-01-21,Mike,suop
|
|
|
```
|
|
|
Command: `./idk scenario7.csv`
|
|
|
Command: `./csv2json scenario7.csv -r [“suop” “soup”]`
|
|
|
|
|
|
Output:
|
|
|
|
|
|
```
|
|
|
|
|
|
date,name,favourite food,
|
|
|
2020-01-21,Mike,soup,
|
|
|
“suop” replaced with “soup” 1 time(s)
|
|
|
``` |
|
|
\ No newline at end of file |