Sign in to follow this  
Followers 0
WhiteBoyCat

Remove Quotations CSV

6 posts in this topic

I am using CVSLib.au3 and taht is a GREAT! Include for Autoit. It has so many great functions. But there is one problem I am facing. With excel it adds quotation marks as escape characters for example: "Spanish, Chris"

I am trying to automate filling and I need the name only. So How do I remove the quotation marks around this name?

The problem is: it is not always the case that I have to remove the quotation marks.

How do I make a check to See if there are quotation marks and remove them if their are?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Something like this. When the first character is a quotation I assume that the tring is quoted.

$sName = '"Spanish, Chris"'
ConsoleWrite("Before: " & $sName & @CRLF)
If Stringleft($sName,1) = '"' Then $sName = StringMid($sName,2,Stringlen($sName)-2)
ConsoleWrite("After: " & $sName & @CRLF)

It could be done with regular expressions using function StringRegExprReplace as well but I'm not familiar with SRE.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Assuming there's no whitespace before/after, you can use this (or add in \s* where necessary):

$sStr='"Spanish, Chris"'
$sStr=StringRegExpReplace($sStr,'(^"|"$)','')

Share this post


Link to post
Share on other sites

Sweet thanks for the advice.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Assuming there's no whitespace before/after, you can use this (or add in s* where necessary):

$sStr='"Spanish, Chris"'
$sStr=StringRegExpReplace($sStr,'(^"|"$)','')

$sStr=StringRegExpReplace($sStr,'^[ ]*"|"[ ]*$','')

This will get the whitespace you're talking about. Also, no point in wasting cycles on capturing if you're not doing anything with it.

Cheers!

Edited by VertigoRay

Figure IT out!http://vertigion.com

Share this post


Link to post
Share on other sites

$sStr=StringRegExpReplace($sStr,'^[ ]*"|"[ ]*$','')

This will get the whitespace you're talking about. Also, no point in wasting cycles on capturing if you're not doing anything with it.

Cheers!

I think he already solved his problem ;)

Hi!


My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s).

My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all!   My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0