Save RTB text to specific CSV cell

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 2 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Save RTB text to specific CSV cell

Post by jvierra »

Still, no idea what you are saying or trying to say ort ask. Too vague. First learn about CSV data and data objects as well as different ways to uupdate a CSV. You cannot just guess, you must gain some understanding of what happens and how to use forms, controls and codde to do what you want.
User avatar
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

Re: Save RTB text to specific CSV cell

Post by localpct »

Within the GUI, I’m only displaying one cell of the entire CSV which is the note column for the user I’m going to specify in a textbox. The CSV has 100s of rows and 10s of columns.

Updating the CSV gives me two results
Everything is wiped but the text displayed in the CSV which is what happens if I use your GUI as is
or a new line in the CSV, which I get when I add -append -force
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Save RTB text to specific CSV cell

Post by jvierra »

You are stilll n ot saying hwat you are trying to do you are only telling us what doesn't work.
If you are trying to edit one cell in a csv then updaate it from the tect box and save the whole CSV back to a file.

You cannot incrementallyh edit a text file. Only open.readd, update and save are possible with any text file. Incremental edits are only possible with data files and database technology or other custom systems like XML and it's associated schemas.
User avatar
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

Re: Save RTB text to specific CSV cell

Post by localpct »

I took your template and made it a bit easier for us - Please load the file
Click create CSV, to create a dummy CSV located C:\temp\book1.csv
Click import CSV
Type in box
Click export
Notice all the populated data is gone?

I understand it's because how I'm viewing the data but can't seem to get around it
Demo-DGVExport (1).psf
(34.31 KiB) Downloaded 100 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Save RTB text to specific CSV cell

Post by jvierra »

You are trying too hard and not seeing what you are doing.
Attachments
Demo-DGVExport_ext.psf
(33.1 KiB) Downloaded 114 times
User avatar
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

Re: Save RTB text to specific CSV cell

Post by localpct »

you took out my code and now I see the whole CSV. I don't want too lol

I just want to see the one cell aka Notes column and what I type in there, gets saved to the same cell on the CSV

I am aware that what you provided me, will do the task by viewing the whole doc. It's also similar to the original example within your first provided form

My actual document is almost 200 rows and 30ish columns
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Save RTB text to specific CSV cell

Post by jvierra »

WHat you are asking can't be done. That is what I have been telling you in multiople ways.

THink your way through it. OPen file, read it, cjhange a cell, save it. If you want to specify a single cell then highlight the cell or uswe a dta object and filter out the cells you need which doies not remove the cells it just hides them. YOu can then still save back the whole CSV.

Until you can understand the limits and why your thinking cvannot work because it is a computer and a text file and then the code all of which require a deeper knowledge and experience than you have. NOw is a chance to rethink things and understand how coded conmputer systems work.

It is how you are thinking about this that is getting in the wqay of your ability to understand the problem. How you are thinking is normal for anyone without any trianing in how computers works, are designed and how the operating system and its support systems work.

A good place to start is to learn PowerSHell correctly and from the beginning. Diong things by copying what you have seen on the Internet or code you may have found will not work as most free code on the Internet is either targetted at something that is not a match for what you require or is just poorly designed or just plain wrong. Think of it as code that may work once under one specific set of circumstances.

Here is a free downloadable book that will reset your thinking along the correct path and simplify everything you may do in the future with PowerShell and with anything you might need to do with computers.

https://www.sapien.com/books_training/W ... werShell-4
User avatar
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

Re: Save RTB text to specific CSV cell

Post by localpct »

Hi, i believe it can be done. Your quick to pass judgement over the screen and assume. You know what they say about that :). As a friendly reminder, you’re the one who suggested a dgv and I asked why. Cheers
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Save RTB text to specific CSV cell

Post by jvierra »

I suggested a DGV because it is the only reasonable way to edit a CSV. Any other mehtod is harder, takes more code and will be just as hard for you to write as this. That is why I suggested reading the book and learning how PowerSHel and computers work. If you learn that then you will see why your question is so hard to answer as you are asking to do something in a specific way that is not possible. This leads you to misunderstanding other wqays that you might use to accomplish your task.

I can onlly make recommendations based on what you tell me and what is possible with these tools. The rest is up to you.

Good luck and please read the book or get another one that will help you move forward correctly.
This topic is 2 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked