Once a beginner, always a beginner! I'm using python 2.7.5, OSX 10.8
You may have the solution to my question even if you don't know pyfits, since I believe it's a problem in my algorithm! I use the following code
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import pyfits
from PySide import QtGui, QtCore
import os
import fonctions
print('\n\n')
directory = raw_input("file path : ")
hdulist=pyfits.open(directory)
print('\n\n')
print('--------------------------------fits informations :')
hdulist.info()
print ('\n\n')
print("\n")
j=0 #PyFITS is using zero-based indexing when referring to HDUs
k=0
while True: #runs through all the HDUs
try:
hdulist[j].header[k] is None
except IndexError: #errors handling when coming to the last HDU
print("--------------------------------No more HDU! \n\n\n\n\n\n")
break
while True: #runs through all the headers
try:
hdulist[j].header[k] is None
except IndexError: #errors handling when coming to the last header
i=0
break
header = hdulist[j].header[k]
print (hdulist[j].header.ascardlist())
k=k+1
j=j+1
It "works" since it displays hdulist[j].header.ascardlist(), but it prints it k times, before going to the next HDU... Any advice?