Skip to content

Commit 9109b76

Browse files
committed
updates
1 parent 190f124 commit 9109b76

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

replaceValueInCommunityFromCSV.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
args = parser.parse_args()
2121

2222
if args.fileName:
23-
fileName = filePath+args.fileName
23+
fileName = filePath+'/ETD RDF/'+args.fileName
2424
else:
25-
fileName = filePath+raw_input('Enter the file name of the CSV of changes (including \'.csv\'): ')
25+
fileName = filePath+'/ETD RDF/'+raw_input('Enter the file name of the CSV of changes (including \'.csv\'): ')
2626
if args.handle:
2727
handle = args.handle
2828
else:
@@ -61,20 +61,24 @@
6161

6262
f=csv.writer(open(filePath+'replacedValues'+datetime.now().strftime('%Y-%m-%d %H.%M.%S')+'.csv', 'wb'))
6363
f.writerow(['handle']+['replacedValue']+['replacementValue'])
64+
with open(fileName) as csvfile:
65+
reader = csv.DictReader(csvfile)
66+
rowCount = len(list(reader))
6467
with open(fileName) as csvfile:
6568
reader = csv.DictReader(csvfile)
6669
for row in reader:
67-
print row
70+
rowCount -= 1
6871
replacedValue = row['replacedValue'].decode('utf-8')
6972
replacementValue = row['replacementValue'].decode('utf-8')
73+
print 'Rows remaining: ', rowCount,
74+
print replacedValue, ' -- ', replacementValue
7075
if replacedValue != replacementValue:
7176
print replacedValue
7277
offset = 0
7378
recordsEdited = 0
7479
items = ''
7580
while items != []:
7681
endpoint = baseURL+'/rest/filtered-items?query_field[]=*&query_op[]=equals&query_val[]='+replacedValue+collSels+'&limit=200&offset='+str(offset)
77-
print endpoint
7882
response = requests.get(endpoint, headers=header, cookies=cookies, verify=verify).json()
7983
items = response['items']
8084
for item in items:

0 commit comments

Comments
 (0)