01-24-2018
Some python code for fun :-)
python code:
#! /usr/bin/env python
from json import load
f_in = open('data.json')
data = load(f_in)
f_in.close()
f_out = open('output.dat', 'w')
for key in ('couchdb', 'httpd_request_methods', 'httpd_status_codes'):
for k1, v1 in data[key].iteritems():
string = "%s, %s=%s, " % ("couchdb", key, k1)
for k2, v2 in v1.iteritems():
string += "%s=%s, " % (k2, v2)
string = string.rstrip(', ') + '\n'
f_out.write(string)
f_out.close()
Last edited by balajesuri; 01-24-2018 at 11:37 AM..
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I am trying to figure out how to split a file when the data in the new line is different from the current line using a shell script?
For eg..
if my input file contains the following
2341123 ABCAD
2341123 ANCAED
2341123 AVADV
3343434 ASDVAV
3343434 ASDFADF
4231232 ADACVAV
4231232... (3 Replies)
Discussion started by: gmatsoon
3 Replies
2. Shell Programming and Scripting
Input file data contents:
>seq_1
MSNQSPPQSQRPGHSHSHSHSHAGLASSTSSHSNPSANASYNLNGPRTGGDQRYRASVDA
>seq_2
AGAAGRGWGRDVTAAASPNPRNGGGRPASDLLSVGNAGGQASFASPETIDRWFEDLQHYE
>seq_3
ATLEEMAAASLDANFKEELSAIEQWFRVLSEAERTAALYSLLQSSTQVQMRFFVTVLQQM
ARADPITALLSPANPGQASMEAQMDAKLAAMGLKSPASPAVRQYARQSLSGDTYLSPHSA... (7 Replies)
Discussion started by: patrick87
7 Replies
3. Shell Programming and Scripting
I’m new to Linux script and not sure how to filter out bad records from huge flat files (over 1.3GB each). The delimiter is a semi colon “;”
Here is the sample of 5 lines in the file:
Name1;phone1;address1;city1;state1;zipcode1
Name2;phone2;address2;city2;state2;zipcode2;comment... (7 Replies)
Discussion started by: lv99
7 Replies
4. Shell Programming and Scripting
Hi,
I have a data file xyz.dat similar to the one given below,
2345|98|809||x|969|0
2345|98|809||y|0|537
2345|97|809||x|544|0
2345|97|809||y|0|651
9685|98|809||x|321|0
9685|98|809||y|0|357
9685|98|709||x|687|0
9685|98|709||y|0|234
2315|98|809||x|564|0
2315|98|809||y|0|537... (2 Replies)
Discussion started by: nithins007
2 Replies
5. Shell Programming and Scripting
I would like break in two line by 'SNAG'
Current data:
SNAG|M1299063| | | | |0001.|0010.|AC64797|2008-02-18|093730.|YVR|AC64797|2008-02-18-09.37.30.250020|N|30|NO LEAKS OR CRACKS THIS A7 SCK SNAG|M1299063| | | |... (10 Replies)
Discussion started by: javeiregh
10 Replies
6. Shell Programming and Scripting
Hi All,
I have file(File1) with data like below:
102100|LName|Gender|Company|Branch|Bday|Salary|Age
102100|bbbb|male|cccc|dddd|19900814|15000|20|
102101|asdg|male|gggg|ksgu|19911216|||
102102|bdbm|male|kkkk|acke|19931018||23|
102102|kfjg|male|kkkc|gkgg|19921213|14000|24|... (2 Replies)
Discussion started by: sarav.shan
2 Replies
7. Programming
I wanted to know what is the best way to query json formatted files for content? Ex. Data
https://usn.ubuntu.com/usn-db/database-all.json.bz2
When looking at keys as in:
import json
json_data = json.load(open('database-all.json'))
for keys in json_data.iterkeys():
print 'Keys--> {}... (0 Replies)
Discussion started by: metallica1973
0 Replies
8. UNIX for Beginners Questions & Answers
Hello,
I need to split a file by number of records and rename each split file with actual filename pre-pended with 3 digit split number.
What I have tried is the below command with 2 digit numeric value
split -l 3 -d abc.txt F (# Will Produce split Files as F00 F01 F02)
How to produce... (19 Replies)
Discussion started by: techedipro
19 Replies
9. UNIX for Beginners Questions & Answers
i use the split command to split a one terabyte backup file into 10 chunks of 100 GB each. The files are split one after the other. While the files is being split, I will like to scp the files one after the other as soon as the previous one completes, from server A to Server B. Then on server B ,... (2 Replies)
Discussion started by: malaika
2 Replies
10. Shell Programming and Scripting
One of the great thing about unix is the ability to pipe multiple programs together to manipulate data. Plain, unstructured text is the most common type of data that is passed between programs, but these days JSON is becoming more popular.
I thought it would be fun to pipe together some command... (1 Reply)
Discussion started by: kbrazil
1 Replies