This is a snippet of powershell code to reformat text file data generated by PI Integrator for BA to json and upload to an Amazon Web Services S3 bucket. It is just a snippet and does not include bucket configuration or authentication.

 

Usage:

Run the script from the same directory as your input files.

Replace <replace_with_bucket> with your bucket name.

The script requires AWS Tools for Windows Powershell in order to run the Write-S3Object cmdlet.

 

The .json generating piece can be tested without an AWS bucket by commenting out these lines:

#Write-S3Object -BucketName replace_with_bucket -File .\$File-$FileNumber.json

<# Delete files #>

#Remove-Item -Path .\$File-$FileNumber.Dat

#Remove-Item -Path .\$File-$FileNumber.json

 

Code snippet is TXT2JSON.ps1 on GitHub: https://github.com/clarksa0/TXT2JSON