Hi there -
Background:
Operator calculates a set of statistics from the total sample size & the respective measurements within sample set of a given lot/batch number. Has to manually load each set of calculations into the selected Sample ID # (Bottom Right).
Table Records ID Nomenclature:
'[Product Code] ‘-’ [Lot Number] ‘-’ [Defect Category] ‘-’ [Sample ID #]
Current Operation:
- Operator Selects Defect Category to find calculations for from the Defect Classification Table (Upper Right)
- Selects a Sample ID Record from the Inspection Table Record (Bottom Right)
- Repeats Calculate to store calculations for each individual sample ID # for the entire sample size.
Is there a way to batch edit multiple inspection records based currently-loaded variables?
Tulip Support gave me this, but I do not want to pull from a .CSV.
import requests
import csv
import json
import time#FACTORY = cooper-usa.tulip.co
FACTORY = ''cooper-usa.tulip.co
authorization = ''Basic …==
AUTHORIZATION = ‘’'Basic… ==
CSV_FILE = ‘’ #CSV local file name
#TABLE_ID = XooSfizhcWqiMnTxx
TABLE_ID = ''XooSfizhcWqiMnTxxendpoint = FACTORY + “/api/v3/tables/” + XooSfizhcWqiMnTxx
response = requests.get(endpoint, headers = {‘Authorization’: AUTHORIZATION})
print(response.json())failedIDs =
success_count = 0
failure_count = 0
endpoint = FACTORY + “/api/v3/tables/” + TABLE_ID + ‘/records’
with open(CSV_FILE, encoding=‘utf8’) as csv_file:
csv_reader = csv.reader(csv_file, delimiter=‘,’)
line_count = 0
for row in csv_reader:
if line_count > 0: # Ignore header rows
# Column mapping should follow the format of ‘COLUMN_ID’: row[COLUMN_INDEX]
# Where COLUMN_ID is defined by the Tulip Table schema i.e. abcde_test
# and COLUMN_INDEX is the column number of the CSV (0-indexed)
column_mapping = {
‘id’ : row[2],
# Example ’xyz_part’ : row[3],
#’ xyz_description’ : row[4],} columns = json.dumps(column_mapping) id = row[2] print(column_mapping) response = requests.post(endpoint, headers = {'Authorization': AUTHORIZATION}, data=columns, verify=False) if response.status_code != 201: print('Posting row {} with id {}, failed with {} response'.format(line_count, id, response)) failedIDs.append(id) failure_count += 1 else: print('Modify successful for ' + id) success_count += 1 time.sleep(0.2) line_count += 1
print(failedIDs)