Best answer

Removing Last Line Of CSV

  • 4 August 2021
  • 6 replies
  • 612 views

Hello!

We have a software in which we export daily data once a day to google drive folder and import it to CSV using the Zapier formatter.  We then do some calculations and send that data to Asana.

We have been able to create some great zaps that work during testing, but when we turn the zap on, we run into an issue.  During testing, the zap only tests 50 rows of the CSV.  Our reports happen to be about 53 rows or so. When the zap is turned on, it process the whole thing.

The main issue is that the last line of the CSV file is always totaling the data above it.  I could solve all my issues if I could remove the last line of the CSV in total or even filter out/remove the last item in each column I am working with.

Here is a screenshot of the CSV File. The highlighted row is the one im trying to remove.

Thanks!

icon

Best answer by nicksimard 5 August 2021, 22:15

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

6 replies

Userlevel 7
Badge +14

Hi @rmjaskie 
Can you provide some screenshots about how your Zap steps are configured for this?

 

Looping is one option for handling line items in a Zap: https://zapier.com/apps/looping/integrations

A Filter step could be added to each loop to check if Last: https://zapier.com/apps/filter/help

How do I stop a loop from running in subsequent action steps?

All actions after the looping step will run for each iteration of the loop. If you don’t want an action step to loop:

  • After the last step you want to loop, add a filter step.
  • Set the filter to only continue if the value loop_iteration_is_last matches the (Boolean) Is True condition.

The filter will run in every loop but will only pass in the last loop. Any actions step after the filter will run once in the last loop and use only 1 task.

 

OR you may need to use a custom Code step to remove the last line in the CSV file: https://zapier.com/apps/code/help

 

I am not seeing my full CSV file when I do a Test Step

As CSV files can be rather large, we limit the Test Step to 1000 characters of text and 50 line-items. Please let us know if this is not enough for you to set up your Zap.

CSV Import only supports file sizes < 150K error

The utility only supports importing files that are 150K or less (which is around 1000 rows of a 10 column CSV file.) You'll need to split the CSV file into multiple files if it's too large.

I figured out a workaround but it is far from elegant.  I haven't really tried looping, but will look into it.  Here are my screenshots of each step, so you can see what I came up with.

 

Userlevel 7
Badge +11

Hi@rmjaskie!

That’s quite a workflow you’ve come up with! I *think* I’m about to make your life a whole lot easier :) 

Assuming you’re fine with sending this data into a Google Sheet (which you probably are, since it’s already in Google Drive) here’s a shortcut for you based on what I believe you’re trying to do:

Trigger: Google Drive — New File
Action: Formatter — Utilities — Import CSV
Action: Google Sheets — Create Spreadsheet Rows (using line items)
Action: Google Sheets — Find Spreadsheet Row (I’ll show you how to find the one you want)
Action: Asana — Create Task

For the Create Row action you’ll want to choose this option:

Your sheet would contain all of the same columns as the CSV, and then add one more for the search step:

Set up the Create Row action like this (it doesn’t matter what you use as the search word, as long as you use it in both Google Sheets steps):

Select the columns that have the dollar amounts in them and format it to Currency:

When you create the rows, all the numbers will be formatted for you:

Now here’s the real magic. On the search step, search by whatever word you added to that Search Word column, and do it bottom-up. That ensures that you’ll always find the last row:

Check it out:

Then you can map those fields into your Asana step where needed :) Now instead of having 21 action steps you’ll have 4. Please let me know if this solves the problem for you!

@nicksimard This is awesome! I can't wait to test it out!

Since we do this on a daily basis, does it just create a new spreadsheet for each day it gets loaded in? Is there a best practice for that?

Userlevel 7
Badge +11

Hi @rmjaskie!

Awesome! If it works out for you, it will make things drastically more simple. You could technically just keep adding to the same spreadsheet, since what you need will always be the bottom row :)

You could get more creative and see if you’re able to create a new worksheet (or spreadsheet) every day but you don’t need that in order to make this solution work. You can add everything to the same worksheet and use it as a utilitarian part of the workflow.

@nicksimard Just circling back on this.  This was super helpful and an easy way to get all the values in one place like that. 


We have a bunch of different calculations that we do with different zaps and I think I can probably use this as a base for each of those.

Question for you though.  If I want to search for specific data, let’s say for 5 specific clients, could I use a similar zap to this to gather or filter their data?