Python> Implementation that synthesizes 3 files with variable columns and outputs 3 items on each line

Operating environment


Xeon E5-2620 v4 (8 cores) x 2
32GB RAM
CentOS 6.8 (64bit)
openmpi-1.8.x86_64 and its-devel
mpich.x86_64 3.1-5.el6 and its-devel
gcc version 4.4.7 (And gfortran)
NCAR Command Language Version 6.3.0
WRF v3.7.Use 1.

Related bash> Implementation that synthesizes 3 files with variable columns and outputs 3 items on each line> Slow implementation and fast implementation Python implementation.

Reference http://stackoverflow.com/questions/7637957/reading-space-separated-input-in-python

combine_3files_170315.py


#!/usr/bin/env python

with open('out_val_170315') as vfp:
	val = vfp.read()
with open('out_lat_170315') as afp:
	lat = afp.read()
with open('out_lon_170315') as ofp:
	lon = ofp.read()

for elm in zip(val.split(),lat.split(),lon.split()):
	print(elm)

Even if I processed it with bash, I felt that Python was easier for the subsequent processing (filtering by latitude / longitude value, etc.), so I changed it to Python.

result


$ python combine_3files_170315.py | head
('0.00', '36.07', '131.17')
('0.00', '36.07', '131.29')
('0.00', '36.07', '131.41')
('0.00', '36.07', '131.53')
('0.00', '36.07', '131.65')
('0.00', '36.07', '131.77')
('0.00', '36.07', '131.89')
('0.00', '36.07', '132.01')
('0.00', '36.07', '132.13')
('0.00', '36.07', '132.25')

Recommended Posts

Python> Implementation that synthesizes 3 files with variable columns and outputs 3 items on each line
A python script that deletes ._DS_Store and ._ * files created on Mac
Read the file with python and delete the line breaks [Notes on reading the file]
Reading and writing JSON files with Python
Download files on the web with Python
Draw a line / scatter plot on the CSV file (2 columns) with python matplotlib
Install OpenCV 4.0 and Python 3.7 on Windows 10 with Anaconda
Drag and drop local files with Selenium (Python)
Implementation of TRIE tree with Python and LOUDS
Download and import files with Splunk external python
Reading and writing fits files with Python (memo)
One-liner that outputs 10000 digits of pi with Python
Sample program that outputs syslog with Python logging
Checks if there is a specific character string for all files under the directory that is Python and outputs the target line
Notes on HDR and RAW image processing with Python
Automatic follow on Twitter with python and selenium! (RPA)
Get comments on youtube Live with [python] and [pytchat]!
I made a LINE BOT with Python and Heroku
Read and write files with Slackbot ~ Bot development with Python ~
Ubuntu 20.04 on raspberry pi 4 with OpenCV and use with python
Email hipchat with postfix, fluentd and python on Azure
Automate Chrome with Python and Selenium on your Chromebook
Scraping with Python + Selenium to add Apple refurbished products to your cart and notify on line