biscayne 0 Light Poster

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.