1

Is it possible to fill text fields in a print composer template using data saved in a csv file?

For example, every template I create has the same fields which I always have to manually enter:

Client name, site name, title

If I were to enter this information into a csv file could I then point the label to the appropriate data using an expression?

  • Could you use an html file in a label box? – Ian Turton May 16 '16 at 13:53
  • How? I have no idea how to do this. – Claire Feldkamp May 16 '16 at 14:09
1

You can view CSV data in a print composer template, but if you save the template the data is not saved with it. As for using a label to view the data I would suggest against it as any code you write to extract from the csv would be far longer than you typing it out anyway.

What I would suggest is you insert an attribute table into the template (this can be saved to the template). That way you can set it up to filter the csv, giving you more scope should you want to use the atlas generation features.

In any case you will always have to load the CSV into QGIS before you can use it in the template.

Alternatively, save the project with everything setup and any layers connected with the project get loaded with it. This will save you time and maintain data connections between the CSV and the print composer attribute table. Hope this helps.

1

You could use this estructure using expressions:

attribute( get_feature( 'X','Y','Z'),'Name')

where:

X --> name or ID of the table (in this case the name of the csv incorporated to qgis. You can call it even if it is not shown into the print composer).

Y --> field for selection (for example 'ID').

Z --> here you should write the value that selects the row of interest.

'Name' --> write here the name of the field of your interest.

Whith this you can save some time because you just need to create an one expresion for 'Client name', 'site name' and 'title' and then just change the 'Z' value to get those values in that row.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.