1

I am exporting csv file from simple feature collection with help of gt-csv the feature collection is coming from db. Export is working fine but i am seeing another temp file generated in the same folder with my table name as prefix and secondly is there any option available in this library so that i can put double quotes on string values.

 CSVDataStore csvStore = null;

    try
    {
          SimpleFeatureCollection coll = getCollectionDB();
        String geometryPropertyName;
        geometryPropertyName = coll.getSchema().getGeometryDescriptor().getLocalName();
        File fileToSave = new File("Export.csv");

        Map<String, Object> cvsParams = new HashMap<>();
        cvsParams.put(CSVDataStoreFactory.FILE_PARAM.key, fileToSave.getAbsolutePath());
        cvsParams.put(CSVDataStoreFactory.STRATEGYP.key, CSVDataStoreFactory.WKT_STRATEGY);     
        cvsParams.put(CSVDataStoreFactory.WKTP.key, geometryPropertyName);
        csvStore = (CSVDataStore) DataStoreFinder.getDataStore(cvsParams);

        csvStore.createSchema(coll.getSchema()); 


        CSVFeatureStore csvFeatureStore = (CSVFeatureStore) csvStore.getFeatureSource(csvStore.getTypeName().getLocalPart());

        csvFeatureStore.addFeatures(coll);

    }
    finally {
        if(csvStore != null)
            csvStore.dispose();
    }   
  • 1
    one question per question please. what is the content of the temp file? – bugmenot123 Nov 8 '18 at 8:06
  • what is the full name of the other file? – Ian Turton Nov 8 '18 at 8:18
  • @IanTurton my table in postgres is "gistable" so file generated is gistable + randomNo i.e (gistable123456.......csv) – Haider Nov 8 '18 at 12:11
1

This seems to be a bug cleaning up the temporary file the writer uses to allow you to back out of a write.

As for forcing quotes on text fields I don't think javacsv 2.0 which is the underlying mechanism we use to write out the data provides that functionality and even if it does it isn't currently exposed through the datastore. I've created an improvement request for an upgrade.

UPDATE

I've pushed a fix.

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.