Python script for "adding" multiple AAVSO.txt reports to ONE report

American Association of Variable Star Observers (AAVSO)
Thu, 08/29/2013 - 21:26

# Easy script v1.0 , Coded by Pierre Hallsten SVO
# Use as you wish!!

import os
import shutil
import fnmatch


This script will read all your AAVSO report textfiles and glue them
together into one file named _mall.txt.
For easy upload to AAVSO

1/ Copy this script and all your report files to whatever dir
2/ Create a subdir namnes res
3/ Copy your header file to res and rename it mall.txt
4/ Run this script from the dir with this script and the AAVSO...text batch

Script will output a new file (_mall.txt) with all your reports glued into one.

You can easily extend or modify script to whatever you need

The header file i use is:


If you have more or fewer lines in your header file you have to change :

offset_end=8 to how many lines your header has -1.


#print "Python is really a great language,", "isn't it?";

shutil.copy2('res/mall.txt', 'res/_mall.txt')
dir = os.getcwd()
allfiles = os.listdir(dir)
print allfiles

out = open("res/_mall.txt", "a+") #read and append

for file in os.listdir('.'):
if fnmatch.fnmatch(file, '*.txt'):
fo = open(file, "r",-1)
for x in xrange(offset_start,offset_end): #skip header lines in files

print "done"