Jump to content
corvo

Text file to Array

Recommended Posts

Hi, I'm trying to populate a 2D array from text file contents. 

the text file has multi-lines/rows, and the word "chat" comes at the end of each line, which I've used as a split character to split rows. Now I'm struggling in column splitting, as I'm trying to split columns by spaces (which are already available in the text file) and can be seen in below data sample. 

here is what I've reached so far

#include <File.au3>
#include <Array.au3>

$file = "c:\test\data.txt"
local $arr = stringsplit(fileread($file),"chat",3)
$arr2 = stringsplit($arr[0]," ",3)
_ArrayTranspose($arr2)
_ArrayDisplay($arr2)

 

It gives me the result I'm looking for, but for one line only. 

Tried For Loop, but it still gives me the data for last row only.

below is a sample of the text data. 

950-138742 System TestQ@DefaultTenant 555555555:Default Question Guest va12 00:00:01 No 01/13/2021 19:59:36 Active chat

950-138741 System TestQV@DefaultTenant 222222222:Default Question Guest tmagalaa 00:00:03 No 01/13/2021 19:59:33 Inactive chat

950-138740 System TestQV2@DefaultTenant 111111111:Default Question Guest esabdelghany 00:00:03 No 01/13/2021 19:59:28 Inactive chat

950-138739 System TestWQA@DefaultTenant 000000000:Default Question Guest saelgabry 00:00:01 No 01/13/2021 19:59:26 Active chat

and here is what my output looks like (which I need to apply on all rows).

image.thumb.png.67a91c2335418167ba781c4389bb2975.png

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...