• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Read a Tab Delimited File

New Here ,
Dec 11, 2006 Dec 11, 2006

Copy link to clipboard

Copied

I found this piece of code on cflib and it works great and is exactly what I need. The one thing that I am missing is how to reference the different data points in the array.
The array is named GetTabTextFeed(list). But how do I reference the array - i.e. GetTabTextFeed(list)[3][2]?

Thanks for the help,

Steve

TOPICS
Advanced techniques

Views

354

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 11, 2006 Dec 11, 2006

Copy link to clipboard

Copied

<cfset x = GetTabTextFeed(list)>
<cfdump var="#x[2][3]#">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 11, 2006 Dec 11, 2006

Copy link to clipboard

Copied

Thanks for the quick reply. It worked perfectly.
Another question - now that I see the results. I have an empty record for some of my data points. This script looks like it should set them to null, but in fact it just skips right over it leaving my array with a dimension of 11 instead of 12. Any ideas why? Is it with my file?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Dec 11, 2006 Dec 11, 2006

Copy link to clipboard

Copied

This is because that UDF uses list functions and list functions do not recognize empty items!!! (No one can provide a GOOD reason why Allaire did that.)

To fix this, rewrite the UDF without list functions or, perhaps this is good enough? :

<cfset explictNulls = REReplace (list, "([\t])\t", "\1[blank]\1", "ALL")>
<cfset x = GetTabTextFeed (explictNulls )>
<cfdump var="#x[2][3]#">


Also, it looks like that UDF might not handle carriage returns (Chr (13)) well.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 11, 2006 Dec 11, 2006

Copy link to clipboard

Copied

MikerRoo,
Thanks for the quick response. This seems to work for all but the first data element. Does this have something to do with the carriage return?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Dec 12, 2006 Dec 12, 2006

Copy link to clipboard

Copied

LATEST
No, the kludge I supplied does not work if the first or last element is blank.

Instead use the new UDF I've attached.

It handles empty values no matter where they are and is 10 to 40% faster.

Finally, your database also handles tab-separated file import. For large files, it is the smart choice.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation