Using the internet information/information using this platform, I manage to write a small Python code which reads 200 csv and then able to distinguish the different values corresponding to the index of the column. Now I am interested in writting a csv/txt file in which 2 columns should there one of variable "time" and another variable "alpha.water" . Using the following Python script I am able to write a single variable "time":
# importing different modules
import os
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import math
import importlib
totalt = 200 # defining the total time
for i in range (0,totalt):
df = pd.read_csv('interpolate_lwc_t_%d.csv'%i, skiprows=0)
# writting file corresponding to this data
x1 = df['Time'].values
tfile = open('test.txt', 'a')
tfile.write(str (x1))
tfile.close()
Also this "time" variable is written with the square bracket [] as follows:
[0.008][0.009][0.01][0.011][0.012][0.013][0.014][0.015][0.016][0.017][0.018][0.019][0.02][0.021][0.022][0.023][0.024][0.025][0.026][0.027][0.028][0.029][0.03][0.031][0.032][0.033][0.034][0.035][0.036][0.037][0.038][0.039][0.04][0.041][0.042][0.043][0.044][0.045][0.046][0.047][0.048][0.049][0.05][0.051][0.052][0.053][0.054][0.055][0.056][0.057][0.058][0.059][0.06][0.061][0.062][0.063][0.064][0.065][0.066][0.067][0.068][0.069][0.07][0.071]
Is there any clearer way of writing a csv/txt file where inside two columns of variable "Time" and "alpha.water", the corresponding values be written? I am expecting the following output:
Time alpha.water
0.008 0.01147
0.009 0.011472
0.010 0.011473
Any suggestion/comment will be a great help. Thanks in advance.