Convert text to Excel file

I want to convert in Excel like

Far. IntVer. RelVer
Naka 10.9 18.9
Paka. Na. Na
Moka 10.8 17.8

From input txt file

Far=naka
IntVer=10.9
RelVer=18.9
Far=paka
Far=moka
IntVer=10.8
RelVer=17.8
Far=sota
Far=kata
IntVer=10.9
RelVer=12.6

How to convert input text to Excel like above using powershell

himanshuk,
Welcome to the forum. :wave:t4:

This forum is for scripting questions rather than script requests. We do not write customized and ready to use scripts or solutions on request.

We actually expect you to make an own attempt at the first place to get your task done or to solve your problem. If you have done so already please document here what exactly you have done and show your code. Then we probably might be able to help you step further.

PowerShell does not support native Excel format (XLS, XLSX) out of the box. You could create CSV output and import it in Excel or you use the great module from Doug Finke

Here you can learn how to use it

And BTW: When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.

Thanks in advance

How to format code in PowerShell.org <---- Click :point_up_2:t4: :wink:

Regardless of all that … I don’t see any obvious relation between the input text you shared and the expected result. Where does this input text come from?

@Olaf I am afraid but due to policy constraint I am unable to open and share the code, I have split and itrate in while loop by get-content |selects-string and it’s about to finish just in case element is absent then NA is unable to add in the logic also the above impoetexcel is not useful in this case I have tried that too, so you throw some light in the area

Of course you should obfuscate or remove any sensitive information. :man_shrugging:t4: We’re not interested in your secrets. We’re interested in helping you. :wink:

I didn’t get that at all. It really does not make any sense to describe the code - just show it.

And again … I cannot see any algorithm yet bringing the text input you shared to the desired output you want. For example: You seem to have 3 columns in the result but there is no sequence of 3 in your input data. And it seems there are values from the input data missing in your result.

And BTW:

When you crosspost the same question at the same time to different forums you should at least post links to the other forums along with your question to avoid people willing to help you making their work twice or more.

Thanks

@Olaf usually I have used stack overflow but I agree and will follow the rule now onwards

It’s not rules, it’s just good etiquette and manners. You could receive an acceptable answer elsewhere while people are spending their time here helping with something you’re not needing help with any more. Plus future visitors may find this question to be exactly like theirs and could benefit from the answer(s), here or elsewhere.

1 Like