By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 890 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

how to add two files using python

P: 3
input1:create external table db.emp(id int,name string)
row formatted fields terminated by ','
location 'hadfs:.../';

create external table db.emp1(id int,name string)
row formatted fields terminated by ','
location 'hadfs:.../';

input2:create external table db.emp(id int,name string)
row formatted fields terminated by ','
location 'hadfs:.../';;
create table db.emp1(id int,name string)
row formatted fields terminated by ','
location 'hadfs:.../';
requeried output:create external table db.emp(id int,name string)
row formatted fields terminated by ','
location 'hadfs:.../';
create external table db.emp(id int,name string)
row formatted fields terminated by ','
location 'hadfs:.../';
these two files stored under file1.hql
******
create external table db.emp1(id int,name string)
row formatted fields terminated by ','
location 'hadfs:.../';
create external table db.emp(id int,name string)
row formatted fields terminated by ','
location 'hadfs:.../';
these two files stored under file2.hql
and so on

i tried with:

filenames = ['in1.txt', 'in2.txt']
with open('result.txt', 'w') as outfile:
for fname in filenames:
with open(fname) as infile:
content = infile.read().replace('\n', '')
outfile.write(content)
but i didn't get requeried output. Please give me a hint how to achieve this.
May 19 '17 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 613
but i didn't get requeried output
What does this mean, that is what did you get and how is it different from what you want? Also, we can not read your code without proper indentation. See the "code" example at https://bytes.com/misc.php?do=bbcode
May 19 '17 #2

Post your reply

Sign in to post your reply or Sign up for a free account.