Member since
04-19-2017
6
Posts
0
Kudos Received
0
Solutions
07-22-2017
08:45 AM
input: one table having 4 columns and I need to edit one column data. Eg:c1,c2,c3,c4 '2014\efd','12',1200\200\1','45' c3 column alone i want the data to be '0001200\0200\01' i need to append zero's infront of the numbers. i want entire column numbers should be '7\4\2'. I have written udf in Python to achieve this.But am getting an error while processing. Please assist me. import sys
for line in sys.stdin:
line = line.strip()
c1,c2,c3,c4 = line.split('\t')
m = line.split("\")
val = m[0]
width = 5
val = val.zfill(width)
val1 = m[1]
width = 4
val1 = val1.zfill(width)
val2 = m[2]
width = 2
val2 = val2.zfill(width)
c3 = p+q+r
print '\t'.join([c1,c2,str(c3),c4])
... View more
Labels:
05-24-2017
05:10 PM
hive tables having different date formats (yyyyddmm:h:m:s and mm/dd/yyyy) I need to convrt into one format i.e. (yyyyddmm). i Have written the code but its not working.
... View more
05-24-2017
02:01 PM
Thanks it's clear but my scenario is different.
... View more
05-24-2017
10:59 AM
how can I achieve using Python
... View more
Labels:
05-19-2017
05:29 AM
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.
... View more
- Tags:
- python