Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7980131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:58:25+00:00 2026-06-04T09:58:25+00:00

I have a CSV to convert. Transforming the data into my schema is a

  • 0

I have a CSV to convert. Transforming the data into my schema is a bit problematic.
I have a locationID in my end table, and in the CSV, there are 1’s or a NULL in about 10 columns(each one is a different location).

My logic is: If column(“locationThree”) == 1, then set locationID to 5 (for example)

I can’t figure out how to do this in SQL, is there a tool for this in Pentaho, or how could I do this in SQL?

E.G

INSERT INTO endTable(locationID)
SELECT * FROM grubbyCSVData
if(locationOne == "1")
 locationID = 5;
if(locationTwo == "1")
 locationID = 6;

Is something like that possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T09:58:27+00:00Added an answer on June 4, 2026 at 9:58 am

    You might like to try combining the COALESCE and CASE expressions in SQL. Assuming you are using SQL Server something like the following might work. I have not verified that this executes correctly as I’ve just written it in the browser.

    INSERT INTO endTable(locationID)
    SELECT COALESCE( CASE locationOne
                     WHEN 1 THEN 5
                     ELSE NULL
                     END,
                     CASE locationTwo
                     WHEN 1 THEN 6
                     ELSE NULL
                     END
                    );
    

    Alternatively you might want to look into the PIVOT and UNPIVOT statements which are available in SQL Server 2005 onwards.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .csv file. I want to convert it into .txt file starting
I have some imported csv data that I have turned into an xts object.
I have a XML data and I need to convert the same to CSV
I'm trying to convert CSV data into paring array data, but I'm totally new
I have a static csv file. I want to covert all the data in
I saw this excellent post: http://sqldud.blogspot.com/2009/01/how-to-convert-csv-to-xml-using-c.html I have a csv file with the column
If you have an URL like this: Java lib or app to convert CSV
I have a csv file being read into python, I then save the reader
I have a text file which I intend to convert to a CSV (in
I have following CSV data: 10,11,12.34 I can parse this using CSV from the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.