Thanks for weighing in.
I see the output from this python script comes as
of 2736 character length.
lengths = (10, 15, 20) defines the length of 3 fields.
The need is not to repeat these 3 sets many times upto 2736 characters
The record structure will have 70-80 fields with mixed types/length like
Name varchar (10)
Business Name varchar (15)
Address Varchar (20)
amount number(12,2)
amount2 number (7,2)
rate number (5,2)
C_name varchar (32)
*
*
*
*
*
*
*
goes to many field definitions upto 70-80
How do I make the output for
If Numeric like number (9,2) with digits
If a character like varchar (20) mix of alphabets & digits
some files use ASCII '\031' as a delimiter. How do I do that in above scripts.
Thanks for your help.
UPDATE
=======
I like to add clarifications to this question:
I have the required spec in a file like
The changed Python script looks like
Any suggestions for improvement in this script?
I am looking to add date data, amount like 9999999.99 as well.
Thanks for your guidance.
Thanks for your guidance.
I see the output from this python script comes as
of 2736 character length.
lengths = (10, 15, 20) defines the length of 3 fields.
The need is not to repeat these 3 sets many times upto 2736 characters
The record structure will have 70-80 fields with mixed types/length like
Name varchar (10)
Business Name varchar (15)
Address Varchar (20)
amount number(12,2)
amount2 number (7,2)
rate number (5,2)
C_name varchar (32)
*
*
*
*
*
*
*
goes to many field definitions upto 70-80
How do I make the output for
If Numeric like number (9,2) with digits
If a character like varchar (20) mix of alphabets & digits
some files use ASCII '\031' as a delimiter. How do I do that in above scripts.
Thanks for your help.
UPDATE
=======
I like to add clarifications to this question:
I have the required spec in a file like
colspec1.data cat colspec1.data 10,x 15,u 20,p 10,9 22,w 18,r 15,9This help me to add many rows as needed.
The changed Python script looks like
from csv import reader final_string = '' # read csv file as a list of lists with open('colspec1.data', 'r') as read_obj: # pass the file object to reader() to get the reader object csv_reader = reader(read_obj) # Pass reader object to list() to get a list of lists data = list(map(tuple, csv_reader)) for length, character in data: print(int(length)) final_string += int(length) * str(character) + '|' print(final_string)
The OUTPUT from this script is 10 15 20 10 22 18 15 xxxxxxxxxx|uuuuuuuuuuuuuuu|pppppppppppppppppppp|9999999999|wwwwwwwwwwwwwwwwwwwwww|rrrrrrrrrrrrHow can I change ASCII '\031' as delimiter instead of '|' in this code ?
Any suggestions for improvement in this script?
I am looking to add date data, amount like 9999999.99 as well.
Thanks for your guidance.
Thanks for your guidance.