Skip to content

Commit ac92461

Browse files
committed
πŸ“¦ NEW: Export to CSV
1 parent bdb9911 commit ac92461

4 files changed

Lines changed: 24 additions & 15 deletions

File tree

β€Ž.github/workflows/export.ymlβ€Ž

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ on:
77
paths-ignore:
88
- '**'
99
- '!sql/**.sql'
10-
- '!scripts/export**.php'
11-
- '!scripts/export_plist.sh'
10+
- '!scripts/export**'
1211

1312
jobs:
1413
export_plist:
@@ -24,7 +23,7 @@ jobs:
2423
shell: bash
2524
run: |
2625
[ -d plist ] || mkdir plist
27-
sh ./scripts/export_plist.sh
26+
# sh ./scripts/export_plist.sh
2827
2928
- name: Upload PLIST Exports
3029
uses: actions/upload-artifact@v2
@@ -33,7 +32,7 @@ jobs:
3332
path: plist
3433

3534
export_json_xml:
36-
name: JSON/XML/YAML
35+
name: JSON/XML/YAML/CSV
3736
needs: export_plist
3837
runs-on: ubuntu-latest
3938

@@ -67,9 +66,11 @@ jobs:
6766

6867
- name: Run Export Scripts
6968
run: |
70-
php scripts/export.php
71-
php scripts/export_xml.php
72-
php scripts/export_yaml.php
69+
# php scripts/export.php
70+
# php scripts/export_xml.php
71+
# php scripts/export_yaml.php
72+
[ -d csv ] || mkdir csv
73+
sh ./scripts/export_csv.sh
7374
7475
- name: Commit changed files
7576
uses: stefanzweifel/git-auto-commit-action@v4.1.6

β€ŽREADME.mdβ€Ž

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
![release](https://img.shields.io/github/v/release/dr5hn/countries-states-cities-database?style=flat-square)
55
![size](https://img.shields.io/github/repo-size/dr5hn/countries-states-cities-database?label=size&style=flat-square)
66

7-
Full Database of city state country available in JSON, SQL, XML, YAML & PLIST Format
7+
Full Database of city state country available in JSON, SQL, XML, PLIST, YAML & CSV Format
88
All Countries, States & Cities are Covered & Populated with Different Combinations & Versions.
99

1010
## Formats Available
@@ -13,17 +13,17 @@ All Countries, States & Cities are Covered & Populated with Different Combinatio
1313
- XML
1414
- PLIST
1515
- YAML
16-
- CSV [WIP]
16+
- CSV
1717

1818
## Distribution Files Info
1919
File | JSON | SQL | XML | PLIST | YAML | CSV
2020
:------------ | :-------------| :-------------| :------------- |:-------------|:-------------|:-------------
21-
Countries | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | WIP
22-
States | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | WIP
23-
Cities | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | WIP
24-
Country+States | :white_check_mark: | NA | :white_check_mark: | :white_check_mark: | :white_check_mark: | WIP
25-
State+Cities | :white_check_mark: | NA | :white_check_mark: | :white_check_mark: | :white_check_mark: | WIP
26-
Country+State+Cities/World | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | WIP
21+
Countries | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark:
22+
States | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark:
23+
Cities | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark:
24+
Country+States | :white_check_mark: | NA | :white_check_mark: | :white_check_mark: | :white_check_mark: | NA
25+
State+Cities | :white_check_mark: | NA | :white_check_mark: | :white_check_mark: | :white_check_mark: | NA
26+
Country+State+Cities/World | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | NA
2727

2828
## Demo
2929
https://dr5hn.github.io/countries-states-cities-database/

β€Žscripts/export_csv.shβ€Ž

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
# Convert MySQL to CSV
4+
for f in 'countries' 'states' 'cities'; do
5+
mysql -uroot -proot world -e "SELECT * FROM ${f} INTO OUTFILE 'csv/${f}.csv' FIELDS TERMINATED BY '|' LINES TERMINATED BY '\n';"
6+
done

β€Žscripts/export_plist.shβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/bin/bash
2+
3+
# Convert JSON to PLIST
24
for f in ./*.json; do
35
[ -e "$f" ] || continue
46
filename="${f%.*}"

0 commit comments

Comments
Β (0)