# Text to column issues

**URL:** https://forums.powershell.org/t/text-to-column-issues/10460
**Category:** PowerShell Help
**Created:** [April 6, 2018, 9:52am UTC](https://forums.powershell.org/t/text-to-column-issues/10460 "2018-04-06T09:52:34Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![fupaflap](https://avatars.discourse-cdn.com/v4/letter/f/94ad74/32.png) [@fupaflap](https://forums.powershell.org/u/fupaflap)
#### Post date: [April 6, 2018, 9:52am UTC](https://forums.powershell.org/t/text-to-column-issues/10460/1 "2018-04-06T09:52:34Z")

</div>

Im pulling a csv file from a putty session output. Im trying to get it properly formatted into columns but since the output doesnt have any commas or tabs and each row has different number of spaces my text to column ps1 doesnt format it correctly unless I do some manual editing of the file which this has to be an automated process due to the amount of files so Im trying to figure out how to get my powershell script to do it correctly. Below is the data I have in .csv, running an import-csv will return this and you can see the space situation Im talking about

```
Name Size Thin Provisioning Data Reduction Total Reduction Volume Snapshots Shared Space System Total  
----------------------------------------------------------------------------------------------------------------------------------
Development_b_001 8T 57% 5.9 to 1 13.7 to 1 548.64G 45.20G - - 593.84G
Production_b_001 8T 36% 3.2 to 1 5.0 to 1 1.57T 0.00 - - 1.57T
```

---

<div class="post-metadata">

### Author: ![js2010](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@js2010](https://forums.powershell.org/u/js2010)
#### Post date: [April 6, 2018, 10:12am UTC](https://forums.powershell.org/t/text-to-column-issues/10460/2 "2018-04-06T10:12:25Z")

</div>

This doesn’t work?

```
import-csv file.csv | format-table -autosize
```

---

<div class="post-metadata">

### Author: ![sanchez](https://avatars.discourse-cdn.com/v4/letter/s/35a633/32.png) [@sanchez](https://forums.powershell.org/u/sanchez)
#### Post date: [April 6, 2018, 10:24am UTC](https://forums.powershell.org/t/text-to-column-issues/10460/3 "2018-04-06T10:24:09Z")

</div>

You might want to try “convertfrom-string”

Check [this](https://cdn-powershell.pressidium.com/wp-content/uploads/2018/02/Iron-Scripter-Prequel-Puzzle-4-A-commentary.pdf) out for some good examples

---

<div class="post-metadata">

### Author: ![ta11ow](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/ta11ow/32/131_2.png) [@ta11ow](https://forums.powershell.org/u/ta11ow)
#### Post date: [April 6, 2018, 10:27am UTC](https://forums.powershell.org/t/text-to-column-issues/10460/4 "2018-04-06T10:27:34Z")

</div>

I would look into the possibilities with **ConvertFrom-String** 🙂

---

<div class="post-metadata">

### Author: ![fupaflap](https://avatars.discourse-cdn.com/v4/letter/f/94ad74/32.png) [@fupaflap](https://forums.powershell.org/u/fupaflap)
#### Post date: [April 6, 2018, 11:06am UTC](https://forums.powershell.org/t/text-to-column-issues/10460/5 "2018-04-06T11:06:27Z")

</div>

Yeah I found ConvertFrom-String while I was googling just struggling to make the -templatefile now but If I can figure this out I think I got it I just dont know the proper syntax to get it just yet. Tried below but its not working how I thought it would.

```
{Name*:*} {Size*:*} {Thin Provisioning*:*} {Data Reduction*:*} {Total Reduction*:*} {Volume*:*} {Snapshots*:*} {Shared Space*:*} {System*:*} {Total*:*}
```

---

<div class="post-metadata">

### Author: ![john-mongelluzzo](https://avatars.discourse-cdn.com/v4/letter/j/73ab20/32.png) [@john-mongelluzzo](https://forums.powershell.org/u/john-mongelluzzo)
#### Post date: [April 6, 2018, 11:23am UTC](https://forums.powershell.org/t/text-to-column-issues/10460/6 "2018-04-06T11:23:45Z")

</div>

Your template is a bit off.

```
instead of your string like this .....
Yours:
{Name*:*} {Size*:*} {Thin Provisioning*:*} 

Try this instead based upon the data:

Name Size Thin Provisioning Data Reduction Total Reduction Volume Snapshots Shared Space System Total  
----------------------------------------------------------------------------------------------------------------------------------
{name*:Development_b_001} {Size:8T} {Thin_provisioning:57%} 
{name*:Production_b_001} {Size:8T} {Thin_provisioning:36%}
```

Make sure you have enough samples to provide to the Convertfrom-string engine in your template file. I would use at least 3 lines, and if they each have slightly different sizes/values that is better.

I also found an earlier post in this forum:  
[https://powershell.org/forums/topic/need-to-read-a-file-and-store-it-in-a-variable/#post-91695](https://powershell.org/forums/topic/need-to-read-a-file-and-store-it-in-a-variable/#post-91695)

---

<div class="post-metadata">

### Author: ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)
#### Post date: [May 16, 2024, 8:35pm UTC](https://forums.powershell.org/t/text-to-column-issues/10460/7 "2024-05-16T20:35:59Z")

</div>


