<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Separate Question and Answer about 1000 topics]]></title><description><![CDATA[<p dir="auto">Please help me to convert the text to CSV as a structure<br />
1.1.1 This is question number 1?<br />
This is answer 1 with opinion 1<br />
This is answer 1 with opinion 2<br />
…<br />
…<br />
1…1.2 This is question number 2?<br />
This is answer 2 with opinion 1<br />
This is answer 2 with opinion 2<br />
…<br />
…</p>
<p dir="auto">And I want to separate into 02 columns with answers and question<br />
I know the question ends with a question mark, and below the question is the answer. But I don’t know how to separate that. Please help me<br />
Thank you very much</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/25962/separate-question-and-answer-about-1000-topics</link><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Apr 2026 00:06:09 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/25962.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 23 Jul 2024 16:02:51 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Separate Question and Answer about 1000 topics on Thu, 25 Jul 2024 03:58:43 GMT]]></title><description><![CDATA[<p dir="auto">Here’s my PythonScript script, which can output a CSV or TSV file while ensuring that each row has the right number of columns and any instances of the column separator inside a column are handled correctly.</p>
<pre><code class="language-py">'''
====== SOURCE ======
Requires PythonScript (https://github.com/bruderstein/PythonScript/releases)
Based on this question: https://community.notepad-plus-plus.org/topic/25962/separate-question-and-answer-about-1000-topics
====== DESCRIPTION ======
Converts a list of questions in the following format into a RFC-4180 compliant CSV file (in other words, a CSV file that is designed to be easy for lots of applications to read)
====== EXAMPLE ======
Assume that you have the text below (between the ------------ lines):
------------
1.1.1 This is question number 1?
"This is answer" 1 with option 1
This, is answer 1, with option 2
1.1.2 This is question number 2?
This is answer 2, with "option 1"
This is answer 2 with option 2
This is answer 2 with option 3
1.1.3 This is question "number 3"?
This is answer 3 with option 1
1.1.4 This is question, number 4?
This is answer 4 with option 1
This is answer 4, with option 2
This is answer 4 with "option" 3
This is answer 4 with option 4
------------
This script will output the following CSV file (between the ------------ lines)
------------
question,option 1,option 2,option 3,option 4
1.1.1 This is question number 1?,"""This is answer"" 1 with option 1","This, is answer 1, with option 2",,
1.1.2 This is question number 2?,"This is answer 2, with ""option 1""",This is answer 2 with option 2,This is answer 2 with option 3,
"1.1.3 This is question ""number 3""?",This is answer 3 with option 1,,,
"1.1.4 This is question, number 4?",This is answer 4 with option 1,"This is answer 4, with option 2","This is answer 4 with ""option"" 3",This is answer 4 with option 4
------------
'''
from Npp import editor, notepad
import json


def convert_q_list_to_csv_main():
    # this is set to ',' to make a CSV file.
    # you could instead use '\t' if you wanted a TSV (tab-separated variables) file
    SEP = ','

    question_lines = []

    def to_RFC_4180(s: str, sep: str) -&gt; str:
        if '"' in s or sep in s or '\r' in s or '\n' in s:
            return '"' + s.replace('"', '""') + '"'
        return s
    
    editor.research(r"((?'question'^\d+\.\d+\.\d+ +(.*\?)$))(?:\R(?!(?&amp;question)).*)+",
        lambda m: question_lines.append(m.group(0).splitlines()))

    print(json.dumps(question_lines, indent=4))

    max_n_options = max(len(x) for x in question_lines)

    header_text = 'question' + SEP + SEP.join('option %d' % ii for ii in range(1, max_n_options))

    out_line_texts = [header_text]

    for question in question_lines:
        RFC_4180_texts = []
        for ii in range(max_n_options):
            if ii &gt;= len(question):
                RFC_4180_texts.append('')
            else:
                RFC_4180_texts.append(to_RFC_4180(question[ii], SEP))
        out_line_texts.append(SEP.join(RFC_4180_texts))

    notepad.new()
    editor.setText('\r\n'.join(out_line_texts))

if __name__ == '__main__':
    convert_q_list_to_csv_main()
    del convert_q_list_to_csv_main
</code></pre>
<p dir="auto">Before you ask, I made the odd programmatic choice to define helper functions and global constants inside the main function to avoid polluting the global PythonScript namespace.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/95880</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/95880</guid><dc:creator><![CDATA[Mark Olson]]></dc:creator><pubDate>Thu, 25 Jul 2024 03:58:43 GMT</pubDate></item><item><title><![CDATA[Reply to Separate Question and Answer about 1000 topics on Wed, 24 Jul 2024 16:21:17 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/27184">@Coises</a> said in <a href="/post/95863">Separate Question and Answer about 1000 topics</a>:</p>
<blockquote>
<p dir="auto">(?-s)^(?!.*?$)</p>
</blockquote>
<p dir="auto">Thank you for your reply, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/27184">@Coises</a><br />
I will try as per your instructions.<br />
Thank you very much</p>
]]></description><link>https://community.notepad-plus-plus.org/post/95869</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/95869</guid><dc:creator><![CDATA[PXuan Tang]]></dc:creator><pubDate>Wed, 24 Jul 2024 16:21:17 GMT</pubDate></item><item><title><![CDATA[Reply to Separate Question and Answer about 1000 topics on Wed, 24 Jul 2024 04:42:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/31209">@PXuan-Tang</a> said in <a href="/post/95859">Separate Question and Answer about 1000 topics</a>:</p>
<blockquote>
<p dir="auto">This is input<br />
1.1.1 This is question number 1?<br />
This is answer 1 with opinion 1<br />
This is answer 1 with opinion 2<br />
…<br />
…<br />
1…1.2 This is question number 2?<br />
This is answer 2 with opinion 1<br />
This is answer 2 with opinion 2<br />
…<br />
…</p>
<p dir="auto">I want to output as picture<img src="/assets/uploads/files/1721787952224-column.png" alt="column.png" class=" img-fluid img-markdown" /></p>
</blockquote>
<p dir="auto">I would do this in multiple steps. First, put a tab character at the beginning of every line that does not end with a question mark:</p>
<p dir="auto"><strong>Find what: <code>(?-s)^(?!.*\?$)</code></strong><br />
<strong>Replace with: <code>\t</code></strong></p>
<p dir="auto">Next, remove the line breaks following the question marks:</p>
<p dir="auto"><strong>Find what: <code>\?\R</code></strong><br />
<strong>Replace with: <code>?</code></strong></p>
<p dir="auto">Now you have the structure you want; the only problem is that the tabs probably don’t line up.</p>
<p dir="auto">The simplest way to fix that is to open <strong>Settings</strong> | <strong>Preferences…</strong>, select <strong>Language</strong> in the box at the left, and then change <strong>Indent size</strong> (which, despite its name, controls the tabulation grid, not just indentation) to a number large enough to move the second column to the right of the longest entry in the first column. You can see it move as you change the number, so it shouldn’t be too hard to find a number that works.</p>
<p dir="auto">From there, you can use <strong>Edit</strong> | <strong>Blank Operations</strong> | <strong>TAB to Space</strong> if you want spaces instead of tabs.</p>
<p dir="auto">If you really want CSV (as stated in your original post) instead of the example you gave, you should probably use a plugin to do the conversion. I can describe how to do it with <strong>Columns++</strong>; others will be more familiar with different plugins.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/95863</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/95863</guid><dc:creator><![CDATA[Coises]]></dc:creator><pubDate>Wed, 24 Jul 2024 04:42:36 GMT</pubDate></item><item><title><![CDATA[Reply to Separate Question and Answer about 1000 topics on Wed, 24 Jul 2024 02:28:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/26710">@Mark-Olson</a> Thank you for your reply,<br />
Please help me to use your script as my case.<br />
Thank,</p>
]]></description><link>https://community.notepad-plus-plus.org/post/95860</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/95860</guid><dc:creator><![CDATA[PXuan Tang]]></dc:creator><pubDate>Wed, 24 Jul 2024 02:28:29 GMT</pubDate></item><item><title><![CDATA[Reply to Separate Question and Answer about 1000 topics on Wed, 24 Jul 2024 02:26:06 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/3841">@PeterJones</a> Hi PeterJones,<br />
Thank you for your reply,</p>
<p dir="auto">This is input<br />
1.1.1 This is question number 1?<br />
This is answer 1 with opinion 1<br />
This is answer 1 with opinion 2<br />
…<br />
…<br />
1…1.2 This is question number 2?<br />
This is answer 2 with opinion 1<br />
This is answer 2 with opinion 2<br />
…<br />
…</p>
<p dir="auto">I want to output as picture<img src="/assets/uploads/files/1721787952224-column.png" alt="column.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Thanks you.</p>
<p dir="auto">…</p>
]]></description><link>https://community.notepad-plus-plus.org/post/95859</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/95859</guid><dc:creator><![CDATA[PXuan Tang]]></dc:creator><pubDate>Wed, 24 Jul 2024 02:26:06 GMT</pubDate></item><item><title><![CDATA[Reply to Separate Question and Answer about 1000 topics on Tue, 23 Jul 2024 18:58:18 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/31209">@PXuan-Tang</a></p>
<p dir="auto">There’s no good way to convert data from that format to a CSV in Notepad++ without using plugins. This is because the text of a question or an option might contain a literal <code>,</code> character or a literal <code>"</code> character, and the presence of those characters in a question or option would require some processing to ensure that the result was a valid CSV file. I don’t believe that regular expressions (which would be the only non-plugin way to do something like this) are a good tool for correctly handling this kind of problem.</p>
<p dir="auto">I have written a script using <a href="https://github.com/bruderstein/PythonScript/releases" rel="nofollow ugc">PythonScript</a> that would address this issue, but before I post it I’d like to know if you’re willing to install a plugin to try to fix this problem, and I’d also like to see if anyone else can come up with a reasonable solution that doesn’t require plugins.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/95854</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/95854</guid><dc:creator><![CDATA[Mark Olson]]></dc:creator><pubDate>Tue, 23 Jul 2024 18:58:18 GMT</pubDate></item><item><title><![CDATA[Reply to Separate Question and Answer about 1000 topics on Tue, 23 Jul 2024 18:49:46 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/31209">@PXuan-Tang</a> said in <a href="/post/95852">Separate Question and Answer about 1000 topics</a>:</p>
<blockquote>
<p dir="auto">And I want to separate into 02 columns with answers and question</p>
</blockquote>
<p dir="auto">Showing us the “after” data would be helpful, because I cannot understand your desired output.</p>
<p dir="auto">When you put int the data, use the <code>&lt;/&gt;</code> button on the forum toolbar while editing your post, and enter your two-column data in between the <code>```</code> lines:</p>
<pre><code>```
put your                example output
here                      please
```
</code></pre>
<p dir="auto">This way, we can be certain how you mean it to look.</p>
<p dir="auto">----</p>
<h3>Useful References</h3>
<ul>
<li><a href="https://community.notepad-plus-plus.org/topic/21965/please-read-before-posting">Please Read Before Posting</a></li>
<li><a href="https://community.notepad-plus-plus.org/topic/22022/template-for-search-replace-questions">Template for Search/Replace Questions</a></li>
<li><a href="https://community.notepad-plus-plus.org/topic/21925/faq-desk-formatting-forum-posts">Formatting Forum Posts</a></li>
<li><a href="https://npp-user-manual.org/docs/searching/#regular-expressions" rel="nofollow ugc">Notepad++ Online User Manual: Searching/Regex</a></li>
<li><a href="https://community.notepad-plus-plus.org/topic/15765/faq-desk-where-to-find-regular-expressions-regex-documentation">FAQ: Where to find other regular expressions (regex) documentation</a></li>
</ul>
]]></description><link>https://community.notepad-plus-plus.org/post/95853</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/95853</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Tue, 23 Jul 2024 18:49:46 GMT</pubDate></item></channel></rss>