Skip to main content

Posts

Showing posts with the label Csv

Logstash : No sincedb_path set, generating one based on the file path while reading csv file

No sincedb_path set, generating one based on the file path Suppose you have a file at location $PATH/a.csv and we want to read and export data( elastic search server).Let's say you are trying to read this log file through the following configuration input { file { path => ["/some/path/a.csv"] start_position => "beginning" } } So, when you run this for the first time, this will work perfectly. The point to note here is that, when you have run this for the first time, logstash will automatically create a sincedb_path file at your home directory and it might look like .sincedb_1a892d89f927eb484cb12a7b7385ab72 . This file tells the logstash that it has already processed this file. If you want to reprocess this file, all you need to do is just delete this file. OR A better solution would be to use the following configurations input { file { path => ["/some/path/a.csv"] start_position => "beginning" sincedb_p...

How to Upload and Read a Csv in Grails

Points To Remember Add the plugin Csv Grails plugin . You can do it manually without the plugin if the you have a uniform structure of the csv file. Upload a Csv  You need to add the dependency for the csv file reader in BUildConfig.groovy as shown below BuildConfig.groovy compile ":csv:0.3.1" And you have a csv file like the following. upload.jsp <g:uploadForm action="upload"> <input type="file" name="file"> <g:submitButton name="file" value="Upload"/> </g:uploadForm> When the above form is submitted then the request will be handled by the controller action as shown below UploadController.groovy def upload() { MultipartFile file = request.getFile( 'file' ) file.inputStream.eachCsvLine { row -> String name = row[1] ?: "NA"; String email = row[2] ?: "NA"; // Business Logic here } } Now you can do your bus...