Reading data from excel few cell values have double quotes How to include the double quotes while reading

0 votes

In excel sheet, I have a column which contains query in this format "sel * from ABC;" . Users will have to give the query with double quotes like this as spark engine process the query in this format.

In java code how can i read this value as it as without excluding the double quotes.

Currently it is read as

"\"select * from ABC;\"" .

how can i make it to

 "select * from from ABC;"
May 7, 2020 in Java by Jyra
• 580 points
2,047 views

1 answer to this question.

0 votes
Best answer

Hi, @Jyra,

You can use one Java function that is Java String Replaceall(): This method finds all occurrences of a sequence of characters matching a regular expression and replaces them with the replacement string. At the end of the call, a new string is returned by the function.

public class Career {
    public static void main(String args[]) {
        String str = "\"select * from ABC;\""
        String str2 = str.replaceAll("\"","");

);

System.out.println(str2);
    }
}

I hope this will help you.

answered May 7, 2020 by Gitika
• 65,910 points

selected May 8, 2020 by Jyra
HI Gitika, the problem is different. In excel it self i give the query in quotes. While java reads this it reads in "\"select * from abc\"" . In excel i gave it as "select * from abc"  [ including quotes].

Fixed this problem. While replacing the backslash, we have to give replace.("\\\\",""). this worked.

Hi, @Jyra,

That's great that you came up with a solution. Bingo!!

Related Questions In Java

0 votes
1 answer

In Java, how to find out the min/max values from array of primitive data types?

import java.util.Arrays; import java.util.Collections; import org.apache.commons.lang.ArrayUtils; public class MinMaxValue { ...READ MORE

answered Jun 12, 2018 in Java by Daisy
• 8,120 points
1,396 views
0 votes
1 answer

How to read text files from the Classpath in Java?

InputStream in = this.getClass().getClassLoader().getResourceAsStream("TextFile.txt"); InputStream in = this.getClass().getResourceAsStream("/TextFile.txt"); package ...READ MORE

answered May 8, 2018 in Java by Akrati
• 3,190 points
2,579 views
0 votes
1 answer

How to refresh a JTable model after insert delete or update the data

In my opinion, you can notify your ...READ MORE

answered Oct 11, 2018 in Java by code.reaper12
• 3,500 points
23,772 views
+2 votes
1 answer

How do I ask the Selenium-WebDriver to wait for few seconds in Java?

There are two ways to wait: explicit ...READ MORE

answered Dec 19, 2018 in Java by Daisy
• 8,120 points

edited Dec 19, 2018 by Daisy 587 views
+5 votes
4 answers

How to execute a python file with few arguments in java?

You can use Java Runtime.exec() to run python script, ...READ MORE

answered Mar 27, 2018 in Java by DragonLord999
• 8,450 points

edited Nov 7, 2018 by Omkar 79,311 views
+1 vote
1 answer

How to handle drop downs using Selenium WebDriver in Java

First, find an XPath which will return ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,500 points
7,921 views
0 votes
1 answer

What are the differences between getText() and getAttribute() functions in Selenium WebDriver?

See, both are used to retrieve something ...READ MORE

answered Apr 5, 2018 in Selenium by nsv999
• 5,500 points
16,941 views
0 votes
1 answer

Selenium JARS(Java) missing from downloadable link

Nothing to worry about here. In the ...READ MORE

answered Apr 5, 2018 in Selenium by nsv999
• 5,500 points

edited Aug 4, 2023 by Khan Sarfaraz 4,357 views
0 votes
1 answer

How to create create an ArrayList from array?

new ArrayList<>(Arrays.asList(array)); READ MORE

answered Dec 21, 2020 in Java by Gitika
• 65,910 points
385 views
0 votes
1 answer

How do I convert from int to String?

Normal ways would be Integer.toString(i) or String.valueOf(i). The concatenation will work, ...READ MORE

answered Dec 30, 2020 in Java by Gitika
• 65,910 points
451 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP