Mercurial > repos > pieterlukasse > prims_metabolomics
view rankfilter_GCMS/pdftotabular.py @ 62:9bd2597c8851 default tip
r
author | pieter.lukasse@wur.nl |
---|---|
date | Fri, 06 Feb 2015 15:49:26 +0100 |
parents | d685210eef3e |
children |
line wrap: on
line source
""" Copyright (C) 2013, Pieter Lukasse, Plant Research International, Wageningen Licensed under the Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ import sys import pdfread from subprocess import call def convert_pdftotext(filename, output_file): ''' Converts PDF file to text @param filename: PDF file to parse @param output_file: output text file for the hits ''' # "-layout" option in pdftotext call below: Maintain (as best as possible) the original physical layout of the text. The # default is to 'undo' physical layout (columns, hyphenation, etc.) and output # the text in reading order. try: call(["pdftotext", "-layout", filename, output_file]) except: raise Exception("Error while trying to convert PDF to text") if __name__ == '__main__': pdf_as_text = sys.argv[1]+".txt" convert_pdftotext(sys.argv[1], pdf_as_text) pdfread.convert_pdftotext2tabular(pdf_as_text, sys.argv[2], sys.argv[3], False)