Jump to content

Text import nightmare


wintergreen
 Share

This topic is 5691 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I'm setting up a script to prompt the user for a text file and then import the data. That's all simple and good, except there's a problem: the text is return-delimited, but contains commas. For the sake of argument, assume it's a chat room log file.

So the text file contents will look like so:

AH: really good, but maybe later...

BP: Yes, I know what you mean.

etc...

What is set up to happen is for the import to take each line and create a new record (which has a single field for now) with all the text. This works fine, except FMP for some reason insists on trying to separate the text by commas. So far I've been unable to find any way around this behaviour.

Some caveats:

-this is on a windows system, so i can't use applescript

-it's for use in a commercial environment, so plugins are out of the question

-the files will always be named with a .txt extension

Any suggestions?

Link to comment
Share on other sites

One way I've done these type files is to import the entire file into one global text field, then parse if from there using either set field or calculated results, but having said that, it is important to note that FM is notoriously slow at dealing with large files this way. If the file is small you can use this method, if large, then I'd rework it in a text editor prior to import.

Rod

Link to comment
Share on other sites

import the entire file into one global text field

This is actually feasible, but how do i set the script to do this? do i just make the import field into a global field?

if large, then I'd rework it in a text editor prior to import.

Not possible unfortunately, that would require the end-users to do it, and that ain't gonna happen...

Link to comment
Share on other sites

I believe that FileMaker defaults to the last File Format used for "That File", otherwise it will default to "All Available". Once you have use the Tab Format, it should default to it until changed to a different Format. You could use a script for this and then it will default to that format, but it is a little clunky if you don't also choose the file.

HTH

Lee

Link to comment
Share on other sites

the problem is that this also changes the file filter (at least on windows), to only show files with a .tab extension. Even worse, some of the text in question to be imported may contain erroneous tab characters, so this would cause the same problem. So far I'm having good results with the web viewer, i'll try to post more about this when i can

Link to comment
Share on other sites

Importing as a .csv/.txt and then Concatenating the fields with a comma inserted probably wouldn't even work. You would have to have more fields than possible commas per line of text. The .csv import would also strip quotes from the text (at least it did on my machine).

You might be able to do this with an XML import but thats out of my league. Unfortunately, I think the best way might be to edit the text outside of filemaker before importing (VBScript may allow you to automate this).

Its a shame that Filemaker does not yet support text imports or exports.

Link to comment
Share on other sites

Are you saying that if the file is a Tab file with a .csv extension on it, that it will be grayed if you select the Tab Format in the import window, and vice versa (.tab and comma format)?

Link to comment
Share on other sites

After playing with using the web viewer to import text some more, it does seem to work as I want it to, except that each line of text renders 3 line break characters after every line. I've no idea what causes it, and worse, because these are not "standard" filemaker line breaks, they can't be filtered out very easily. the only option i have at this point is to try and filter out all empty lines i suppose

Link to comment
Share on other sites

This topic is 5691 days old. Please don't post here. Open a new topic instead.

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
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.