We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,485 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

1 output file instead of multiple files

Thw following piece of code generates 1 file for each row in csvData.
I want to generate only 1 file and have already adapted the rest of the code.
But not this main-loop.

Is there an easy way to do this ?

index = 0
# Generate the Scribus Files
for row in csvData:
    if(index == 0): # Do this only for the first line which is the Header-Row of the CSV-File
        headerRowForFileName = row
        logging.debug('Before conversion: ' + str(row))
        headerRowForReplacingVariables = self.handleAmpersand(row) # Header-Row contains the variable names
        logging.debug('After conversion: ' + str(headerRowForReplacingVariables))
        # Copy the original/given Scribus file to a temporary file which acts as a template
        template = self.copyScribusContent(self.readFileContent(self.__dataObject.getScribusSourceFile()))
    else:
        outContent = self.replaceVariablesWithCsvData(headerRowForReplacingVariables, self.handleAmpersand(row), self.copyScribusContent(template))
        logging.debug('Replaced Variables With Csv Data')
        outputFileName = self.createOutputFileName(index, self.__dataObject.getOutputFileName(), headerRowForFileName, row)
        scribusOutputFilePath = self.createOutputFilePath(self.__dataObject.getOutputDirectory(), outputFileName, CONST.FILE_EXTENSION_SCRIBUS)
        self.exportSLA(scribusOutputFilePath, outContent)
        outputFileNames.append(outputFileName)
        logging.debug('Scribus File CREATED: ' + str(scribusOutputFilePath))
    index = index + 1
1
Contributor
0
Replies
1
View
biscayne
Light Poster
36 posts since Nov 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0500 seconds using 2.65MB