File tree 1 file changed +49
-0
lines changed
1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change
1
+ """
2
+ This script uploads the pickled NSRDB files to AWS.
3
+ """
4
+
5
+ import boto3
6
+ import os
7
+ import nsrdbtools
8
+ s3 = boto3 .client ('s3' )
9
+ import glob
10
+
11
+ # filename_list = glob.glob('/Users/toddkarin/Documents/NSRDB_compressed/*')
12
+
13
+ bucket = 'pvtools-nsrdb-pickle'
14
+
15
+ client = boto3 .client ('s3' )
16
+
17
+ # for j in range(len(filename_list)):
18
+ # for j in [0,1,2]:
19
+ # print('Iteration: {:.0f}, Complete: {:.3f}%'.format(j, j / len(filename_list) * 100))
20
+ # filename_to_upload = filename_list[j]
21
+ # filename_on_server = os.path.split(filename_list[j])[-1]
22
+
23
+
24
+ filename_to_upload = '2017DesignConditions_s.xlsx.csv'
25
+ filename_on_server = filename_to_upload
26
+ client .upload_file (filename_to_upload , bucket , filename_on_server )
27
+
28
+ #
29
+ # try:
30
+ # client.upload_file(filename_to_upload, bucket, filename_on_server)
31
+ # except Exception as e:
32
+ # print(e)
33
+ # else:
34
+ # print("Successful upload to S3 bucket " + str(
35
+ # bucket) + " of file " + filename_to_upload)
36
+
37
+
38
+
39
+ print ('--------' )
40
+ print ('files on server:' )
41
+ # List files on server
42
+ s3 = boto3 .resource ('s3' )
43
+ my_bucket = s3 .Bucket (bucket )
44
+
45
+ # Loop through items and print
46
+ for item in my_bucket .objects .all ():
47
+ if item .key == filename_on_server :
48
+ print ('Successful upload.' )
49
+ print (item .key )
You can’t perform that action at this time.
0 commit comments