I have one CSV file with invoices list to paid.
Example:
Account Number;Invoice Number;Amount
11111;ID11111;100.50
11111;ID22222;250.50
22222;ID33333;100.00
11111;ID44444;300.00
Now I want read this file and create file like this:
Account Number;Invoice Number;Amount
11111;ID11111, ID22222, ID44444;651.00
22222;ID33333;100.00
Second field have been merged and the third field summed.
But second field must have a maximum of 50 characters and next must go to next line.
Related
I have created a new screen where I'm uploading Amazon orders from a CSV file. The original CSV file downloaded needs to have the first few lines removed to have the column headings at the top.
Before
After
I have a data field on the screen called date/time, but when I upload the CSV the mapping finds some sort of hidden characters in the file so the mapping doesn't automatically map the field.
I have tried changing the encoding while uploading the file, as well as changing the display name to include the ??? and double quotes like the image below, but the field doesn't auto-map.
Is there someway to get the field to auto-map on the file upload so the user doesn't have to map the field manually?
Thanks,
Kurt Bauer
Despite searching both Google and the documentation I can't figure this out:
I have a CSV file that has a header line, like this:
ID,Name,Street,City
1,John Doe,Main Street,Some City
2,Jane Done,Sideroad,Other City
Importing into FileMaker works well, except for two things:
It imports the header line as a data set, so I get one row that has an ID of "ID", a Name of "Name", etc.
It assigns the items to fields by order, including the default primary key, created date, etc. I have to manually re-assign them, which works but seems like work that could be avoided.
I would like it to understand that the header line is not a data set and that it could use the field names from the header line and match them to the field names in my FileMaker table.
How do I do that? Where is it explained?
When you import records, you have the option to select a record in the source file that contains field names (usually the first row). See #4 here.
Once you have done that, you will get the option to map the fields automatically by matching names.
If you're doing this periodically, it's best to script the action. A script will remember your choices, so you only need to do this once.
I need to create a CSV file from an API which requires two lines at the top of the CSV file.
The first line would be the name of the program (one column) and the second one a header with a modified name of the columns. I managed to get the second line but I'm not sure I can easily create the first one.
What's the best way to do it?
dfb.select("name1","firstname1").write()
.format("csv")
.option("header",true)
.save("file:///home/dse/bin/results.csv");
I'm working on a flow where I get CSV files. I want to put the records into different directories based on the first field in the CSV record.
For ex, the CSV file would look like this
country,firstname,lastname,ssn,mob_num
US,xxxx,xxxxx,xxxxx,xxxx
UK,xxxx,xxxxx,xxxxx,xxxx
US,xxxx,xxxxx,xxxxx,xxxx
JP,xxxx,xxxxx,xxxxx,xxxx
JP,xxxx,xxxxx,xxxxx,xxxx
I want to get the field value of the first field i.e, country. Put those records into a particular directory. US records goes to US directory, UK records goes to UK directory, and so on.
The flow that I have right now is:
GetFile ----> SplitText(line split count = 1 & header line count = 1) ----> ExtractText (line = (.+)) ----> PutFile(Directory = \tmp\data\${line:getDelimitedField(1)}). I need the header file to be replicated across all the split files for a different purpose. So I need them.
The thing is, the incoming CSV file gets split into multiple flow files with the header successfully. However, the regex that I have given in ExtractText processor evaluates it against the splitted flow files' CSV header instead of the record. So instead of getting US or UK in the "line" attribute, I always get "country". So all the files go to \tmp\data\country. Help me how to resolve this.
I believe getDelimitedField will only work off a singular line and is likely not moving past the newline in your split file.
I would advocate for a slightly different approach in which you could alter your ExtractText to find the country code through a regular expression and avoid the need to include the contents of the file as an attribute.
Using a regex of ^.*\n+(\w+) will capture the first line and the first set of word characters up to the comma and place them in the attribute name you specify in capture group 1. (e.g. country.1).
I have created a template that should get the value you are looking for available at https://github.com/apiri/nifi-review-collateral/blob/master/stackoverflow/42022249/Extract_Country_From_Splits.xml
As the title states - I need a script that allows me to enter a CSV filename and an associated row number which when executed displays that data in that row number of the specified CSV file.
Context: I have an SSIS packet that imports transaction records that I download from another company into SQL every day. The file is in CSV format and when there is an issue with the data in a row I get a truncation error stating that it occurred on (X) row.
The csv files are very large and opening them in Excel isn't a possibility.
(Import-csv filename.csv)[9]
This will find the 10th record (it is a zero indexed array, so the first item is number 0, not 1)
Import-Csv will parse every record in the file, so depending on the size of the "very large" file, you may need other solutions.
If you just want to see the row unparced
(Get-content filename.csv)[9]
Again, this is zero indexed.