0

Suppose we have a HIVE table like this

 name id age

 jones 12 34
 george joseph 13 45
 bush 15 23

Now i want to output this hive table to csv and pipe separated file. I followed steps in How do I output the results of a HiveQL query to CSV?.

 hive -e 'select books from table' | sed 's/[[:space:]]\+/,/g' > /home/lvermeer/temp.csv

But its working this these

      name    id     age
      jones   12     34
      george  joseph 13  45
      bush    15     23

I want george joseph to be in 1 column. Since george joseph contains middle spaces, its outputting to next column. How to resolve this problem ??

Community
  • 1
  • 1
vkele
  • 1
  • 2

2 Answers2

0

In case your query doesnt contain join or so criterias then You could easily get the data from the corresponding HDFS location. The data would be |(pipe) seperated as per the delimiters mentioned.

K S Nidhin
  • 2,622
  • 2
  • 22
  • 44
0

Hive columns are separated by '\t', assuming "george" and "joseph" are separated by space, you don't have any problems. You can check out separators with vim, just type :set list. Tabs would be marked as ^I

To view output file, you can use, for example, LibreOffice Calc, but you have to be sure, that you are using as delimiters only tabs, not spaces

nosmo
  • 108
  • 7