How to combine files with ";" - multiple-columns

I have two text files. One file has a list of names, and the second file has a list of phone numbers. I'd like to create a file with name;phonenumber. Any idea how I can combine the two files?
File 1 has 20k+ entries with names. File 2 has 20k+ entries with the corresponding phone number. I'd like the new file to be:
name1;phone1;
name2;phone2;
I am using Notepad++.

Related

Diffrent column names

I have 74 csv files.
I am merging in SSIS. The data in all are the same, but the column names are different in half.
How can I do mapping?
The column name is [Latitude] in one sample file and [Lat] in the other.
If the column ordinal position for Latitude/Lat is always the same i.e. third column in the file, then you can modify your flat file connection manager to skip the first row and that your file does not have header rows. This will result in you having to manually define your file layout but it's entirely workable.
If lat is column 4 in one file and Latitude is always column 1, the best solution is to have two connection managers - one for each file type and segment your data files by folder and route them into different foreach file enumerators and dataflows for consumption by the target tables.

Apache Nifi: Merge rows in two csv files

I have two csv files that are funnelled into a MergeContent Processor. I want them to be merged together. They both have the same columns. If the first and second csv's look like this:
First CSV:
id, name
12,John
11,Keels
Second CSV:
id, name
22,Kelly
25,Felder
My output should look like this:
id, name
12,John
11,Keels
22,Kelly
25,Felder
I have tried doing this through the MergeContent Processor. But it Changes the data into a different format I don't want that to happen. Both the Input files and the output files must be .csv and also contain the same name as the input files. (The input files have the same name)
Use MergeRecord processor with the common attribute. For example, both flow files have the same attribute such as filename = test.csv then you can set the MergeRecord processor as follows:
Record Reader CSVReader
Record Writer CSVRecordSetWriter
Merge Strategy Bin-Packing Algorithm
Correlation Attribute Name filename
Attribute Strategy Keep Only Common Attributes
Minimum Number of Records 3
The important thing is the minimum number of records, which is the number of rows to be merged. In this case, it should be larger than 2 because each CSV has 2 rows. Then, the CSV will wait for the other CSV to exceed the minimum.

Combine all csv file with different date name into one csv file using batch script

Combine all csv file with different date name into one csv file using batch script
I have file csv like this:
Alarm2017-03-02_1.csv
Alarm2017-03-02_2.csv
Alarm2017-03-03_1.csv
Alarm2017-03-03_2.csv
Alarm2017-03-03_3.csv
Alarm2017-03-03_4.csv
Alarm2017-03-04_1.csv
Alarm2017-03-04_2.csv
Alarm2017-03-04_3.csv
and there is new csv file every minute
with format name like this:
AlarmYYYY-MM-DD_[number sometimes from 1 till 2, or 1 till 4 or 1 till 3 or 1 till 22].csv
how to combine all csv file like that into one using batch script
what you want is to concatenate the files: see this super-user threaed: https://superuser.com/questions/111825/a-command-line-or-batch-cmd-to-concatenate-multiple-files

NiFi : Regular Expression in ExtractText gets CSV header instead of data

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

Read CSV file and create new CSV file in VBScript?

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.