Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Identify if the input file is csv or tsv

geeman
8 - Asteroid

Hi All,

 

I am trying to find a way to identify whether a user inputted file format is a .csv or .tsv. Since I often find this scenario where the expected input file format is a comma delimited and the user inputs a tab separated file (since both opens up similarly in excel) and breaks rest of the workflow. Any thoughts or suggestions? Thanks in advance!

 

Best,

G

 

9 REPLIES 9
patrick_mcauliffe
14 - Magnetar
14 - Magnetar

@geeman  Do you just need to know if it is TSV vs CSV (result in true/false), or do you need to be able to import and use it regardless of which it is?

BenMoss
ACE Emeritus
ACE Emeritus

I am under the assumption this is for an application based on the server? If so I can't see an easy way around this as Alteryx seems to return the error 'c:\...tsv' is not valid.

If it is for users running an application on their local machine then there is a relatively straight forward fix but I am under the assumption this isn't the case.

 

I would perhaps just ensure your users understand the difference between .tsv. and .csv files and how easy it is to convert a .tsv to .csv.

Perhaps I am misinterpreting the problem, and it's actually a .csv file they are trying to input but it is tab delimited within the .csv file (this is possible though it sounds like it isn't!). If this is the case then I believe we can create a fix too.

Ben

geeman
8 - Asteroid

Yes, this is for the application based on the server. Ideally the user downloads the file from a crosstab from a Tableau server as csv, edits the file and upload the file though the alteryx process. But the file downloaded is sometimes downloaded as tsv based on the browser & OS. This breaks the Alteryx workflow since it is expecting a csv. So I need to identify the delimiter  at the beginning of the workflow.

Thanks for your help @BenMoss and @patrick_mcauliffe.

patrick_mcauliffe
14 - Magnetar
14 - Magnetar

@geeman

I would worry less about trying to identify the format and just parse the input as if both were coming in.

In the attached example, you could either drop this in front of your existing workflow or build it into a macro and put it first inline.  Try disconnecting one of the inputs and see how it still parses?  

Of course you'll probably have to modify it a bit for your specific use.  But without knowing much about the data you expect to come in, this is the way I'd do it.

BenMoss
ACE Emeritus
ACE Emeritus
Patrick that would be exactly what I would suggest, importing it as a undelimited file and then parsing accordingly.

However it is my understanding that Alteryx server will just reject a ‘.tsv’ file as an unrecognised type (again only if it actually does contain the .tsv suffix). And you can’t use the ‘update value’ option on a server input as it can’t load the file in this way from the users local machine.
BenMoss
ACE Emeritus
ACE Emeritus
My understanding could be wrong of course! And again the issues I point out are purely if the file actually has the .tsv suffix, I have a feeling they don’t, in which case your workflow will work a charm!
patrick_mcauliffe
14 - Magnetar
14 - Magnetar

@BenMoss @geeman

I misunderstood the question - 

Check out this app instead.  Use the extension to change the delimiter.

 

geeman
8 - Asteroid

Thank you @BenMoss@patrick_mcauliffe! To answer your question.. the file extension would be a .csv and not .tsv. So the input logic is supposed to interpret whether it is an actual comma separated or tab separated. I will give it a try with the solutions you have provided. Cheers!

geeman
8 - Asteroid

Hi @patrick_mcauliffe, I did some tweaking and this is working just fine... Thanks a lot, appreciate your help!

 

Best,

Labels