initial commit
This commit is contained in:
commit
b969ad8689
3 changed files with 29 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
*.csv
|
||||
*.json
|
4
README.md
Normal file
4
README.md
Normal file
|
@ -0,0 +1,4 @@
|
|||
|
||||
```shell
|
||||
bun convert.js ./path/to/csv
|
||||
```
|
23
convert.js
Normal file
23
convert.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
const file = Bun.file('./data.csv');
|
||||
|
||||
const results = {};
|
||||
for (const line of (await file.text()).split('\n').slice(1)) {
|
||||
if (line.trim() === '') {
|
||||
continue;
|
||||
};
|
||||
|
||||
const [industry, market, worker_rating, active_members, show_rate] = line.replaceAll('%', '').split(',');
|
||||
if (!results[industry]) {
|
||||
results[industry] = {}
|
||||
}
|
||||
if (!results[industry][market]) {
|
||||
results[industry][market] = {}
|
||||
}
|
||||
|
||||
results[industry][market] = {
|
||||
worker_rating,
|
||||
active_members,
|
||||
show_rate
|
||||
};
|
||||
}
|
||||
console.log(JSON.stringify(results, null, 3));
|
Loading…
Add table
Reference in a new issue