Trimming string from oracle
<p>I'm attempting, poorly, to compare two lists of filenames and provide a list of the differences.  I have read and attempted the numerous examples available.
Before you close this as a Duplicate, or Already Answered, please read further.</p>

<p>In python, I'm making a call via ftp to obtain a list of files.  This returns an array as expected. Next, I'm calling Oracle to retrieve a list of filenames.
This returns an array of filenames, but the cx_oracle module returns them as <code>('filename',)</code>. When I do a compare, it is comparing filename against <code>('filename',)</code> and fails.  I need to remove the single quote, parentheses and comma prior to the compare. But I'm having zero luck.
I'm attempting to trim these extra characters out of the string using slicing, but this is failing.</p>

<pre><code>for file from resultset:
    print file
    print file[2:10]
</code></pre>

<p>This returns <code>()</code>, rather than filename as expected.
I have tried slicing the string, I have attempted to use awk, but the metacharacters are making this difficult.<br>
If anyone can provide guidance, I would greatly appreciate it.
I have spent hours on something that should have taken minutes.</p>

<p>Thank you, Allan</p>

<p>So first of all if you want to remove characters from both sides of a string you can use <code>lstrp</code> and <code>rstrip</code>.</p>

<pre><code>&gt;&gt;&gt; "('filename')".lstrip("('")
'filename')'
&gt;&gt;&gt; "('filename')".rstrip("')")
"('filename"
</code></pre>

<p>But I suspect that the return data is actually a tuple and not a string</p>

<pre><code>&gt;&gt;&gt; ('filename',)
('filename',)
&gt;&gt;&gt; type(('filename',))
&lt;class 'tuple'&gt;
&gt;&gt;&gt; ('filename',)[2:20]
()
</code></pre>

<p>Which will allow you to say</p>

<pre><code>('filename',)[0]
'filename'
</code></pre>

python cx-oracle