-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathimportmongo.sh
54 lines (31 loc) · 1.07 KB
/
importmongo.sh
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
source ~/.bash_profile
mkdir add add2 halfhourly hhblock other
sudo pip install pandas
aws s3 cp s3://smart-meters/halfhourly/ halfhourly --recursive --acl public-read
aws s3 cp s3://smart-meters/hhblock_dataset/ hhblock --recursive --acl public-read
aws s3 cp s3://smart-meters/other/ other --recursive --acl public-read
echo "import sys
import pandas as pd
import glob
import sys
data = []
globbed_files = glob.glob("*.csv")
import os
for csv in globbed_files:
frame = pd.read_csv(csv, low_memory = False)
frame['filename'] = os.path.basename(csv)
name = "../%s/new" % (sys.argv[1])
frame.to_csv(name + csv)
print csv" >> merge.py
cp merge.py halfhourly/
cp merge.py hhblock/
cd halfhourly
python merge.py add
cd ../add
for i in *.csv; do mongoimport -d smart -c energy --type csv --file $i --headerline ; done
cd ../hhblock
python merge.py add2
cd ../add2
for i in *.csv; do mongoimport -d wide -c energy --type csv --file $i --headerline ; done
cd ../other
for i in *.csv; do mongoimport -d other -c $i --type csv --file $i --headerline ; done