1,105,386 Community Members

1 output file instead of multiple files

Member Avatar
biscayne
Light Poster
36 posts since Nov 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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
You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article