Forum Discussion
Baron164
Mar 21, 2022Brass Contributor
Need to convert a text file into a CSV
I have a text file from payroll that includes all active employees and their relevant information such as Phone Number, Office Location etc. I need to convert this file into a CSV so I can more easil...
Baron164
Mar 22, 2022Brass Contributor
I do not see an option of attaching a text file to my posts so I put an example text file here. https://1drv.ms/t/s!AoktdqajV6ZomugfGxVBbjxHMnua7A?e=rHqB3P
The list is updated on a regular basis so this process needs to be automated. And unfortunately I am not able to make changes to the export process at this time so I'm stuck dealing with the file as is.
The list is updated on a regular basis so this process needs to be automated. And unfortunately I am not able to make changes to the export process at this time so I'm stuck dealing with the file as is.
Mar 22, 2022
Baron164 I think you can use something like this per line, the FIRST_NAME value is $line.SubString(0,5) for example. MI is $line.SubString(31,1). If everything always has the same starting point and a max amount of characters.. You can make variables out of that as input for your update script
- Baron164Mar 22, 2022Brass ContributorOk, so regards to "(31,1)", is 31 the space where that field begins? If that's the case then what does the 1 represent?
- Mar 22, 2022The amount of characters, could be 2 to include the "."
- Baron164Mar 22, 2022Brass ContributorThat makes sense thanks. My main concern is that, while unlikely, it's possible that this file could change in the future and I'd hate to manually specify "31" in a script and then the column width changes and 31 becomes 33 and the script breaks 1000 accounts. So I want to have the script pull the space automatically by reading the hyphens and figuring out where each column starts.