Last active
August 29, 2015 14:23
-
-
Save chapinb/103c5a813c3f0fc53fea to your computer and use it in GitHub Desktop.
Sample Replacement
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This will do the bulk of the data based on the sample, you will have to add in headers and the accrual amounts. The script is not complete, but includes most of the info needed to get started/research | |
## Steps | |
# 1. define lists | |
# a. list of company names | |
# b. list of input data to iterate over int the for loop | |
# c. empty list to apply input data to after it has been processed in the loop | |
# 2. Iterate over input list | |
# a. replace values | |
# b. | |
import random | |
import os | |
company_and_name_list = [] # have sample names here, both company and personal | |
data_len = len(company_and_name_list) | |
open csv file | |
output_lines = [] | |
for line in csv file | |
comma_value = line.split(',') | |
if comma_value[0] is not None: | |
try: | |
int(comma_value[0]) | |
except TypeError: | |
# The first column cannot be converted to an int | |
output_lines.append(line) | |
else: # if it could be converted to an int... | |
# Modify Column C | |
comma_value[2] = 'AP-' + '{:05}'.format(str(random.random_int(0, 99999))) | |
# Modify Column D | |
# Build String | |
# Company Name / IN: RANDINT 6digit | |
cname = company_and_name_list[random.random_int(0, data_len)] | |
str_int = '{:05}'.format(str(random.random_int(0, 99999))) | |
comma_value[3] = cname + ' /IN: ' + str_int | |
output_lines.append(comma_value[1] + ',' + comma_value[2] + ',' + comma_value[3] + ',' + ....) | |
for line_out in output_lines: | |
pass # Add output writing here | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment