Replacing copyright symbol python - python-3.10

I'm trying to remove copyright symbols in my dataframe. I can recognise the symbol using:
symbol = u'\N{COPYRIGHT SIGN}'.encode('utf-8')
symbol = symbol.decode('utf-8')
But when I then try to replace it, this doesn't work:
print(df_one.replace(symbol, ''))
Do I need to read the data in differently somehow? I'm currently using:
df_one = pd.concat(map(pd.read_csv, glob.glob('data/*.csv')))

You should use the "loc" method with the replace function:
df.loc[:, "column_name"].replace({character},regex=True)

averroes response almost worked. This is the solution I now have that does work:
df.loc[:, "column_name"].replace({symbol: ' '},regex=True)

Related

Reactjs convert input string to upper case

I'm creating an app in Reactjs using react-strap. I would like to convert an input field to upper case.
From googling, it looks like simply appending "toUpperCase()" to the field would work, but this doesn't appear as an option in Visual Studio code.
I had a similar issue with doing a replace all, but finally got that to work using "const" field:
// replace ":" with "-"
const phrase = item.macs;
const replaced = phrase.replace(/:/g, '-')
item.macs = replaced;
However, converting to a const field doesn't work for making the "toUpperCase()" available.
What should I do to turn this into a string so I can call the "toUpperCase()" function?
Edit: change references from "toUpper" to "toUpperCase". The problem is this is not available as a function.
For example of I do
'myString'.toUpperCase();
it works. But it I can't get it to bring that up in Visual Studio Code, and it's ignored if I code it anyway.
I believe you are looking after toUpperCase.
To make a string uppercase in javascript you can call .toUpperCase() method on it. For example
const foo = 'foo'
const fooUpper = foo.toUpperCase()
console.log(fooUpper) // expected result 'FOO'
I got around this problem by forcing the input item to be regarded as a string by prepending it with a '', like so:
item.macs = '' + item.macs;
item.macs = item.macs.replace(/:/g, '-');
item.macs = item.macs.toUpperCase();
After that, all the string functions were available.

Parse url query parameters in C glib?

Is it possible to get URL fragment parameters in C under glib ?
I've got a url like file://localhost/home/me/notepad.txt#line=100,2
What's the best way to get the parameters specified at the end of the url ?
There’s no single GLib function which will do what you want. If you can use libsoup (also part of the GNOME stack), then you can do it using SoupURI:
g_autoptr(SoupURI) uri = soup_uri_new (uri_string);
const gchar *fragment = soup_uri_get_fragment (uri);
That will set fragment to line=100,2. You’ll have to do further parsing of whatever your fragment format is, by hand. g_strsplit() would be useful for that.
You may also take a look on the function parse_sftp_uri from gnome-terminal terminal-nautilus.c file.
It can be easily adapted for general URIs.
Unsure if you mean to parse notepad.txt#line=100,2 or #line=100,2, nevertheless my answer should work in both cases.
You can use the strrchr() (man strrchr) function to get the last occurence of a character within a string.
Something like:
char *file;
file = strrchr(url, '/') + 1;

JOOQ: 3.10.5 concat string value with field

I'm new to JOOQ and using the latest version of JOOQ (3.10.5).
I am using it just as a SQL builder and not executing it against any DB.
I created the DSLContext using
Connection creatorConn = null;
creator = DSL.using(creatorConn, SQLDialect.MYSQL_8_0);
When i tried to concat an arbitrary String 'CC_' with a qualified field name field("TBL.[COLUMN NAME]") then resulting field is like
'CC'_ || "TBL.[COLUMN NAME]"
Then, when i use getSQL(), i got something like
select concat(?, TBL.[COLUMN NAME])
Can someone please tell me what went wrong and why is it the string concatenated has been replaced with a ?.
As per the solution posted here by Lukas Eder
I just added the
ParamType.INLINED to the Query.getSQL()
method which resolved this issue. Thanks

ColdFusion server file with apostrophe character

When I try to upload a file with apostrophe, I get the error:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
if the file name is test's.pdf, I get the error. But if I change the name to test.pdf, there is no error.
Does anyone know why?
Thanks
I had a similar situation where I was dynamically creating filenames for pages that created excel files from query results. The approach I took was to create a function that replaced all the bad characters with something. Here is part of that function.
<cfargument name="replacementString" required="no" default=" ">
<cfscript>
var inValidFileNameCharacters = "[/\\*'?[\]:><""|]";
return reReplace (arguments.fileNameIn, inValidFileNameCharacters, arguments.replacementString, "all");
</cfscript>
You might want to consider an opposite approach. Instead of declaring invalid characters and replacing them, declare valid ones and replace anything that is not in the list of valid characters.
I suggest making this a function that's available on all appropriate pages. How you do that depends on your situation.
My guess is that the apostrophe is one of those multi-character apostrophes that Microsoft Word often uses. A character like that may not be a valid character for your OS file system.
You may want to re-code the system to use a temporary file on upload and then rename it to a valid file name after the upload is successful.
Here's some basic trouble shooting info.
Wrap your code in a try/catch block and dump the full error to the page output. Examples of using try/catch/dump below. The examples below force an error by dividing by zero.
For tag based cfml:
<cftry>
<cfset offendingCode = 1 / 0>
<cfcatch type="any">
<cfdump var="#cfcatch#" label="cfcatch">
</cfcatch>
</cftry>
For cfscript cfml:
<cfscript>
try {
offendingCode = 1 / 0;
} catch (any e) {
writeDump(var=e, label="Exception");
}
</cfscript>

Why am I able to directly use some of the ruby C extension array methods, but not others?

I am using many of the array methods found in array.c of the ruby codebase, but when trying to call
VALUE rIntersection = rb_ary_and(rAry1, rAry2);
I got this error:
dyld: lazy symbol binding failed: Symbol not found: _rb_ary_and
Referenced from: ./ext/ev/counters.bundle
Expected in: flat namespace
In other areas of my code I am using rb_ary_sort_bang, rb_ary_clear, rb_ary_reverse, etc etc. So I'm not sure why rb_ary_and is any different.
Have a look at http://www.ruby-doc.org/doxygen/1.8.4/array_8c-source.html (Line 2666)
There you can see that the method rb_ary_and is declared static. This means that it is only visible inside of array.c.
Untested, but I would assume this would work:
rb_funcall( rAry1, rb_intern("&"), 1, rAry2 )

Resources