Previous page | Data Integration | Next page |
Bulk importing from CSV files |
LoadFormFromCsv.wsf This utility allows you to bulk import from a CSV file to a Table, with each line in the CSV file generating a new Record in the Table. When run it will import each line of the CSV file into a separate new record in the specified Table. See also: Updating existing records If you want the import to update some existing records, rather than always append, you need to mark the fields that should be used to match against (fields are marked with a U - see syntax below). Typically this will be a field containing a unique product identifier. If there is a match, then the existing record is updated, and it's built-in updated date/time field is updated to the moment of import. Deleting old records In a typical import and update scenario, there will be some old records which were not updated, and their absence from the import file means they are no-longer needed, and should be deleted from the table. To identify which records should be deleted, once the import stage is complete, the system inspects the built-in updated date/time field for each record, and deletes any record which is 'old' - ie which has a date earlier than when the import process started. It only does this if one or more of the field are marked with a D (see syntax below). However since tables often consist of an aggregate of import from different sources (for example, a product table might contain data from several supplier, each with their own import file) it is important to only delete old record from the same source that the current import file is processing. To assist with this, the field that identifies the source (ie the supplier) can be marked. (fields are marked with a D - see syntax below). As the import stage is executed, a list is kept of all different values of this field (which may be just be the one same value for an import from a single supplier), and all old records matching all these values are then deleted. Note: When a Record is added, any Events (sending emails etc) that would normally be triggered by the addition of a Record will be triggered. If you are bulk loading a large amount of records you should therefore be careful you do not overwhelm your email system.The utility is provided in the form of a script, LoadFormFromCsv.wsf, which should be installed and run from the neatComponents server itself. It is include din the msi install, and is found by default at: C:\Program Files\Enstar\neatComponents\Scripts Note that the CSV file should not contain a set of field names as its first line, or it will attempt to import them as a record too.The script can be placed in any location, but we recommend the Enstar\neatComponents\Scripts directory. Example usage: C:\>cscript "C:\Program Files\Enstar\neatComponents\scripts\LoadFormFromCsv.wsf" /siteid 107 /formid 55 /fields "[1,U2,3,D4>25]" /csvpath "C:\myCsv.csv" /filespath "C:\myFiles"
Syntax: cscript [script path] /siteid {siteid} /formid {formid} /fields "{fields list}" /csvpath "{full path to csv file}" /filespath "{full path to location of images / files for import into records}" [/separator {"char"}]
Note: on 64bit operating systems run c:\windows\syswow64\cscript instead of cscript
[script path]
/siteid
/formid
/fields
/csvpath
/filespath
/separator
Usage suggestionsUse the Upload component to upload the csv file, and any other files or images involved in the import, to the server. (This will ensure they have the correct permissions on the server). After you have run the import script, you can delete the uploaded files using the Upload component (right click on a file, and choose Delete). If you are uploading a set of files or images:
To create a file with a list of the files in a folder, browse to the folder at a command prompt, and type: dir /B > files.csv This will create a file named files.csv, containing a list of the filename, one per line. If you then need to add extra columns in to this, you can open the files.csv file in Excel, add the columns, and resave it in csv format. Direct ODBC connection While it will be possible to use ODBC to access the database, such access bypasses the business rules and security inherent in neatComponents, and is not supported for general use cases. Instead, we provide a scripting interface described above that allows programmatic data access, with the same safety restrictions and triggers as if the data were entered via the web user interface. If you have an application that would only function using a direct ODBC connection please contact us to discuss your requirement. |