Link to home
Start Free TrialLog in
Avatar of Loyall
LoyallFlag for Netherlands

asked on

Powershell partial identical values two csv files

Hi,

I have two quite large csv files that contain values like this:

File one:
000074-e8ec29,33
00c0af-012651,28

file two:
000074 Amsterdam,On
00C0AF Berlin,Add

Is there a way that I can make powershell compare the first six digits of file one and two an than combine those in a new file, so it give me:

000074-e8ec29,33,000074 Amsterdam,On
00c0af-012651,28,00C0AF Berlin,Add

Thanks in advance !!
Avatar of Dan Craciun
Dan Craciun
Flag of Romania image

Not directly.
But you can use pretty much any programming language (including powershell) to:
- read the first file line by line
- for each line search in the second file for a line starting with the first 8 characters of the current line
- if found, add it to the current line and write it to another file

If no one shows with a script by tonight I'll write one.

HTH,
Dan
Does "quite large" mean that we cannot cache at least one of them in memory? If we can't, a slow, filesystem based merge have to be done.
Surely you can just first divide them into 2 parts with Data "-" this can now in 2 sheets be used to do Vlookup

- Rancy
Excel with your exaamples above

- Rancy
EE.xlsx
Avatar of Loyall

ASKER

Hi,

I,m sorry for my delayed response. Personal issues took control.
Dan, is your offer to write a script still valid ?

Kind regards,
Loyall
Loyall,

please answer my question in http:#a41238506, so we can suggest a best-effort script (slow and file based versus fast and memory based).
Avatar of Loyall

ASKER

Hi Qlemo,

The files can be cached in memory.

Kind regards,
Loyall
ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Loyall

ASKER

Thank you very much Qlemo !!